diff --git a/src/pyedb/grpc/edb.py b/src/pyedb/grpc/edb.py index 6e801766e5..93206352ea 100644 --- a/src/pyedb/grpc/edb.py +++ b/src/pyedb/grpc/edb.py @@ -70,6 +70,9 @@ from zipfile import ZipFile as zpf from ansys.edb.core.geometry.polygon_data import PolygonData as GrpcPolygonData +from ansys.edb.core.hierarchy.layout_component import ( + LayoutComponent as GrpcLayoutComponent, +) import ansys.edb.core.layout.cell from ansys.edb.core.simulation_setup.siwave_dcir_simulation_setup import ( SIWaveDCIRSimulationSetup as GrpcSIWaveDCIRSimulationSetup, @@ -3834,3 +3837,38 @@ def compare(self, input_file, results=""): else: self.logger.info("Comparison correctly completed") return True + + def import_layout_component(self, component_path) -> GrpcLayoutComponent: + """Import a layout component inside the current layout and place it at the origin. + This feature is only supported with PyEDB gRPC. Encryption is not yet supported. + + Parameters + ---------- + component_path : str + Layout component path (.aedbcomp file). + + Returns + ------- + class:`LayoutComponent `. + """ + + return GrpcLayoutComponent.import_layout_component(layout=self.active_layout, aedb_comp_path=component_path) + + def export_layout_component(self, component_path) -> bool: + """Export a layout component from the current layout. + This feature is only supported with PyEDB gRPC. Encryption is not yet supported. + + Parameters + ---------- + component_path : str + Layout component path (.aedbcomp file). + + Returns + ------- + bool + `True` if layout component is successfully exported, `False` otherwise. + """ + + return GrpcLayoutComponent.export_layout_component( + layout=self.active_layout, output_aedb_comp_path=component_path + ) diff --git a/tests/grpc/system/test_edb.py b/tests/grpc/system/test_edb.py index 766427d2fe..0795aa95f0 100644 --- a/tests/grpc/system/test_edb.py +++ b/tests/grpc/system/test_edb.py @@ -1971,3 +1971,13 @@ def test_compare_edbs(self, edb_examples): assert edbapp.compare(edb_base) folder = edbapp.edbpath[:-5] + "_compare_results" assert os.path.exists(folder) + + def test_create_layout_component(self, edb_examples): + edbapp = edb_examples.get_si_verse() + out_file = os.path.join(self.local_scratch.path, "test.aedbcomp") + edbapp.export_layout_component(component_path=out_file) + assert os.path.isfile(out_file) + edbapp.close() + edbapp = Edb(edbversion=desktop_version) + layout_comp = edbapp.import_layout_component(out_file) + assert not layout_comp.cell_instance.is_null