From fb455eb81005fb61c270eded0a197c7de455cce1 Mon Sep 17 00:00:00 2001 From: gkorompi Date: Thu, 19 Dec 2024 21:44:51 +0200 Subject: [PATCH 1/4] FEATURE: get the path of a circuit component --- .../core/modeler/circuits/primitives_circuit.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/ansys/aedt/core/modeler/circuits/primitives_circuit.py b/src/ansys/aedt/core/modeler/circuits/primitives_circuit.py index 6f7567451dd..17b23fb6bd4 100644 --- a/src/ansys/aedt/core/modeler/circuits/primitives_circuit.py +++ b/src/ansys/aedt/core/modeler/circuits/primitives_circuit.py @@ -1255,6 +1255,23 @@ def create_wire(self, points, name=""): except Exception: return False + @pyaedt_function_handler() + def component_path(self, component_name): + """Component definition path. + Parameters + ---------- + component_name: str + Name of the component. + """ + for component in self.components.values(): + if component.component_info["InstanceName"] == component_name: + component_definition = component.component_info["Info"] + if not self.o_component_manager.GetData(component_definition): + self.logger.warning("Component has no path") + return False + else: + return (self.o_component_manager.GetData(component_definition)[24][1][12][1].split(" ")[1])[1:-1] + class ComponentInfo(object): """Manages Circuit Catalog info.""" From d154fbfce2b245edf2de90a73121656a8c77a5dd Mon Sep 17 00:00:00 2001 From: gkorompi Date: Fri, 20 Dec 2024 10:20:25 +0200 Subject: [PATCH 2/4] FEAT: get the path of a circuit component 2 --- .../core/modeler/circuits/object_3d_circuit.py | 12 ++++++++++++ .../core/modeler/circuits/primitives_circuit.py | 17 ----------------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/ansys/aedt/core/modeler/circuits/object_3d_circuit.py b/src/ansys/aedt/core/modeler/circuits/object_3d_circuit.py index 6c67f490567..b761c50c2e4 100644 --- a/src/ansys/aedt/core/modeler/circuits/object_3d_circuit.py +++ b/src/ansys/aedt/core/modeler/circuits/object_3d_circuit.py @@ -1084,6 +1084,18 @@ def create_pin_def(pin_name, x, y, angle): self._circuit_components.oeditor.MovePins(self.composed_name, -0, -0, 0, 0, ["NAME:PinMoveData"]) return True + @pyaedt_function_handler() + def component_path(self): + """Component definition path.""" + component_definition = self.component_info["Info"] + if not self._circuit_components.o_component_manager.GetData(component_definition): + self.logger.warning("Component has no path") + return False + else: + return ( + self._circuit_components.o_component_manager.GetData(component_definition)[24][1][12][1].split(" ")[1] + )[1:-1] + class Wire(object): """Creates and manipulates a wire.""" diff --git a/src/ansys/aedt/core/modeler/circuits/primitives_circuit.py b/src/ansys/aedt/core/modeler/circuits/primitives_circuit.py index 782b266d7d8..b5f32fc57d3 100644 --- a/src/ansys/aedt/core/modeler/circuits/primitives_circuit.py +++ b/src/ansys/aedt/core/modeler/circuits/primitives_circuit.py @@ -1239,23 +1239,6 @@ def create_wire(self, points, name=""): except Exception: return False - @pyaedt_function_handler() - def component_path(self, component_name): - """Component definition path. - Parameters - ---------- - component_name: str - Name of the component. - """ - for component in self.components.values(): - if component.component_info["InstanceName"] == component_name: - component_definition = component.component_info["Info"] - if not self.o_component_manager.GetData(component_definition): - self.logger.warning("Component has no path") - return False - else: - return (self.o_component_manager.GetData(component_definition)[24][1][12][1].split(" ")[1])[1:-1] - class ComponentInfo(object): """Manages Circuit Catalog info.""" From d3248ba7ff3756b89b175c66f357b0fc9f0de039 Mon Sep 17 00:00:00 2001 From: gkorompi Date: Mon, 23 Dec 2024 09:23:34 +0200 Subject: [PATCH 3/4] FEAT: get the path of a circuit component 3 --- .../aedt/core/modeler/circuits/object_3d_circuit.py | 12 ++++++------ tests/system/general/test_21_Circuit.py | 8 ++++++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/ansys/aedt/core/modeler/circuits/object_3d_circuit.py b/src/ansys/aedt/core/modeler/circuits/object_3d_circuit.py index b761c50c2e4..eccb274ea4d 100644 --- a/src/ansys/aedt/core/modeler/circuits/object_3d_circuit.py +++ b/src/ansys/aedt/core/modeler/circuits/object_3d_circuit.py @@ -1084,17 +1084,17 @@ def create_pin_def(pin_name, x, y, angle): self._circuit_components.oeditor.MovePins(self.composed_name, -0, -0, 0, 0, ["NAME:PinMoveData"]) return True - @pyaedt_function_handler() + @property def component_path(self): """Component definition path.""" component_definition = self.component_info["Info"] if not self._circuit_components.o_component_manager.GetData(component_definition): - self.logger.warning("Component has no path") + self._circuit_components._app.logger.warning("Component has no path") return False - else: - return ( - self._circuit_components.o_component_manager.GetData(component_definition)[24][1][12][1].split(" ")[1] - )[1:-1] + for i in self._circuit_components.o_component_manager.GetData(component_definition): + if type(i) == list and type(i[0]) == str: + if i[0] == "NAME:CosimDefinitions": + return (i[1][12][1].split(" ")[1])[1:-1] class Wire(object): diff --git a/tests/system/general/test_21_Circuit.py b/tests/system/general/test_21_Circuit.py index cb00a8bbe25..1202630bc40 100644 --- a/tests/system/general/test_21_Circuit.py +++ b/tests/system/general/test_21_Circuit.py @@ -410,6 +410,7 @@ def test_29_create_circuit_from_spice(self): assert self.aedtapp.modeler.schematic.create_component_from_spicemodel(model) assert self.aedtapp.modeler.schematic.create_component_from_spicemodel(model, "GRM2345", False) assert not self.aedtapp.modeler.schematic.create_component_from_spicemodel(model, "GRM2346") + assert list(self.aedtapp.modeler.components.components.values())[0].component_path def test_29a_create_circuit_from_spice_edit_symbol(self): model = os.path.join(TESTS_GENERAL_PATH, "example_models", test_subfolder, "test.lib") @@ -1011,3 +1012,10 @@ def test_53_import_table(self): assert self.aedtapp.delete_imported_data(table) assert table not in self.aedtapp.existing_analysis_sweeps + + def test_54_get_component_path(self): + model = os.path.join(TESTS_GENERAL_PATH, "example_models", test_subfolder, "test.lib") + assert self.aedtapp.modeler.schematic.create_component_from_spicemodel(model) + assert list(self.aedtapp.modeler.components.components.values())[0].component_path + assert self.aedtapp.modeler.components.create_component(component_library="", component_name="RES_") + assert not list(self.aedtapp.modeler.components.components.values())[1].component_path From 941583b5c2059a8ec313f43d0cc8fa443deef55e Mon Sep 17 00:00:00 2001 From: gkorompi <156683163+gkorompi@users.noreply.github.com> Date: Mon, 23 Dec 2024 09:26:28 +0200 Subject: [PATCH 4/4] Update test_21_Circuit.py --- tests/system/general/test_21_Circuit.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/system/general/test_21_Circuit.py b/tests/system/general/test_21_Circuit.py index 1202630bc40..5206963e6e5 100644 --- a/tests/system/general/test_21_Circuit.py +++ b/tests/system/general/test_21_Circuit.py @@ -410,7 +410,6 @@ def test_29_create_circuit_from_spice(self): assert self.aedtapp.modeler.schematic.create_component_from_spicemodel(model) assert self.aedtapp.modeler.schematic.create_component_from_spicemodel(model, "GRM2345", False) assert not self.aedtapp.modeler.schematic.create_component_from_spicemodel(model, "GRM2346") - assert list(self.aedtapp.modeler.components.components.values())[0].component_path def test_29a_create_circuit_from_spice_edit_symbol(self): model = os.path.join(TESTS_GENERAL_PATH, "example_models", test_subfolder, "test.lib")