.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples\gallery_examples\02-importing\import_odb_archive.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_gallery_examples_02-importing_import_odb_archive.py: .. _ref_import_odb_archive: ==================== Import ODB++ Archive ==================== This example demonstrates how to launch the Sherlock gRPC service, import an ODB++ archive, and handle common exceptions during the import process. Description Sherlock's gRPC API enables automation of various workflows, including importing ODB++ archives. This script demonstrates how to: - Connect to the Sherlock service. - Import an ODB++ archive. - Handle import errors gracefully. .. GENERATED FROM PYTHON SOURCE LINES 36-45 .. code-block:: Python import os from examples.examples_globals import get_sherlock_tutorial_path from ansys.sherlock.core import launcher from ansys.sherlock.core.errors import SherlockImportODBError .. GENERATED FROM PYTHON SOURCE LINES 47-50 Connect to Sherlock =================== Connect to the Sherlock service and ensure proper initialization. .. GENERATED FROM PYTHON SOURCE LINES 50-53 .. code-block:: Python sherlock = launcher.connect(port=9092, timeout=10) .. GENERATED FROM PYTHON SOURCE LINES 54-57 Delete Project ============== Delete the project if it already exists. .. GENERATED FROM PYTHON SOURCE LINES 57-64 .. code-block:: Python try: sherlock.project.delete_project("Test") print("Project deleted successfully.") except Exception: pass .. GENERATED FROM PYTHON SOURCE LINES 65-68 Import ODB++ Archive ==================== Import an ODB++ archive provided with the Sherlock installation. .. GENERATED FROM PYTHON SOURCE LINES 68-84 .. code-block:: Python try: odb_path = os.path.join(get_sherlock_tutorial_path(), "ODB++ Tutorial.tgz") sherlock.project.import_odb_archive( archive_file=odb_path, process_layer_thickness=True, include_other_layers=True, process_cutout_file=True, guess_part_properties=True, ims_stackup=True, project="Test", cca_name="Card", ) print("ODB++ archive imported successfully.") except SherlockImportODBError as e: print(f"Error importing ODB++ archive: {e}") .. _sphx_glr_download_examples_gallery_examples_02-importing_import_odb_archive.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: import_odb_archive.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: import_odb_archive.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: import_odb_archive.zip `