Note
Go to the end to download the full example code.
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.
import os
from examples.examples_globals import get_sherlock_tutorial_path
from ansys.sherlock.core import launcher
from ansys.sherlock.core.errors import SherlockImportODBError
Connect to Sherlock#
Connect to the Sherlock service and ensure proper initialization.
sherlock = launcher.connect(port=9092, timeout=10)
Delete Project#
Delete the project if it already exists.
try:
sherlock.project.delete_project("Test")
print("Project deleted successfully.")
except Exception:
pass
Import ODB++ Archive#
Import an ODB++ archive provided with the Sherlock installation.
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}")