From fb455eb81005fb61c270eded0a197c7de455cce1 Mon Sep 17 00:00:00 2001 From: gkorompi Date: Thu, 19 Dec 2024 21:44:51 +0200 Subject: [PATCH 01/10] 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 02/10] 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 03/10] 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 04/10] 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") From 24b67a509456fbf012b381fdf2a8d1e4ccaa14f7 Mon Sep 17 00:00:00 2001 From: gkorompi Date: Sun, 12 Jan 2025 20:31:05 +0200 Subject: [PATCH 05/10] FEAT: get the path of a circuit component 4 --- .../aedt/core/modeler/circuits/object_3d_circuit.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 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 204384e7661..42441ea5f54 100644 --- a/src/ansys/aedt/core/modeler/circuits/object_3d_circuit.py +++ b/src/ansys/aedt/core/modeler/circuits/object_3d_circuit.py @@ -1088,13 +1088,13 @@ def create_pin_def(pin_name, x, y, angle): def component_path(self): """Component definition path.""" component_definition = self.component_info["Info"] - if not self._circuit_components.o_component_manager.GetData(component_definition): + component_data = self._circuit_components.o_component_manager.GetData(component_definition) + if not component_data: self._circuit_components._app.logger.warning("Component has no path") return False - 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] + for data in component_data: + if isinstance(data, list) and isinstance(data[0], str) and data[0] == "NAME:CosimDefinitions": + return (data[1][12][1].split(" ")[1])[1:-1] class Wire(object): From 63754c746f660be8e7c8ee3f4ed28bd5ec7caeea Mon Sep 17 00:00:00 2001 From: gkorompi Date: Tue, 14 Jan 2025 14:19:11 +0200 Subject: [PATCH 06/10] FEAT: get the path of a circuit component 5 --- src/ansys/aedt/core/modeler/circuits/object_3d_circuit.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 42441ea5f54..94b287ae803 100644 --- a/src/ansys/aedt/core/modeler/circuits/object_3d_circuit.py +++ b/src/ansys/aedt/core/modeler/circuits/object_3d_circuit.py @@ -1090,7 +1090,7 @@ def component_path(self): component_definition = self.component_info["Info"] component_data = self._circuit_components.o_component_manager.GetData(component_definition) if not component_data: - self._circuit_components._app.logger.warning("Component has no path") + self._circuit_components._app.logger.warning("Component " + self.component_info["RefDes"] + " has no path") return False for data in component_data: if isinstance(data, list) and isinstance(data[0], str) and data[0] == "NAME:CosimDefinitions": From cdc8d2fd2f10aa40fb972a064543013646c212d2 Mon Sep 17 00:00:00 2001 From: gkorompi Date: Tue, 14 Jan 2025 14:24:58 +0200 Subject: [PATCH 07/10] FEAT: get the path of a circuit component 5 --- src/ansys/aedt/core/modeler/circuits/object_3d_circuit.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 94b287ae803..f2dc0e8948c 100644 --- a/src/ansys/aedt/core/modeler/circuits/object_3d_circuit.py +++ b/src/ansys/aedt/core/modeler/circuits/object_3d_circuit.py @@ -1090,7 +1090,7 @@ def component_path(self): component_definition = self.component_info["Info"] component_data = self._circuit_components.o_component_manager.GetData(component_definition) if not component_data: - self._circuit_components._app.logger.warning("Component " + self.component_info["RefDes"] + " has no path") + self._circuit_components._app.logger.warning("Component " + self.refdes + " has no path") return False for data in component_data: if isinstance(data, list) and isinstance(data[0], str) and data[0] == "NAME:CosimDefinitions": From dcf3bfa7056a4926f834ebcbe67c5d28c918da53 Mon Sep 17 00:00:00 2001 From: gkorompi Date: Tue, 14 Jan 2025 22:15:46 +0200 Subject: [PATCH 08/10] FEAT: get the path of a circuit component 5 --- .../aedt/core/modeler/circuits/object_3d_circuit.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 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 f2dc0e8948c..22d16e35ba8 100644 --- a/src/ansys/aedt/core/modeler/circuits/object_3d_circuit.py +++ b/src/ansys/aedt/core/modeler/circuits/object_3d_circuit.py @@ -1092,9 +1092,12 @@ def component_path(self): if not component_data: self._circuit_components._app.logger.warning("Component " + self.refdes + " has no path") return False - for data in component_data: - if isinstance(data, list) and isinstance(data[0], str) and data[0] == "NAME:CosimDefinitions": - return (data[1][12][1].split(" ")[1])[1:-1] + if len(component_data[2][5]) == 0: + for data in component_data: + if isinstance(data, list) and isinstance(data[0], str) and data[0] == "NAME:CosimDefinitions": + return (data[1][12][1].split(" ")[1])[1:-1] + else: + return component_data[2][5] class Wire(object): From 684cb5bef86be5c2d48842e5496df0204f97f109 Mon Sep 17 00:00:00 2001 From: gkorompi Date: Tue, 21 Jan 2025 12:22:12 +0200 Subject: [PATCH 09/10] FEAT: get the path of a circuit component 6 --- .../core/modeler/circuits/object_3d_circuit.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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 22d16e35ba8..7bb7527a545 100644 --- a/src/ansys/aedt/core/modeler/circuits/object_3d_circuit.py +++ b/src/ansys/aedt/core/modeler/circuits/object_3d_circuit.py @@ -1099,6 +1099,23 @@ def component_path(self): else: return component_data[2][5] + @property + def component_path(self): + """Component definition path.""" + component_definition = self.component_info["Info"] + component_data = self._circuit_components.o_component_manager.GetData(component_definition) + if not component_data: + self._circuit_components._app.logger.warning("Component " + self.refdes + " has no path") + return False + if len(component_data[2][5]) == 0: + for data in component_data: + if isinstance(data, list) and isinstance(data[0], str) and data[0] == "NAME:CosimDefinitions": + if len(data[1][12]) == 0: + return component_data[17][2][4] + return (data[1][12][1].split(" ")[1])[1:-1] + else: + return component_data[2][5] + class Wire(object): """Creates and manipulates a wire.""" From 80e4003b29be4275bcd46b10b02a4feec1e20b85 Mon Sep 17 00:00:00 2001 From: gkorompi Date: Tue, 21 Jan 2025 12:23:57 +0200 Subject: [PATCH 10/10] FEAT: get the path of a circuit component 6 --- .../core/modeler/circuits/object_3d_circuit.py | 15 --------------- 1 file changed, 15 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 7bb7527a545..38b7df2ab1e 100644 --- a/src/ansys/aedt/core/modeler/circuits/object_3d_circuit.py +++ b/src/ansys/aedt/core/modeler/circuits/object_3d_circuit.py @@ -1084,21 +1084,6 @@ 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 - @property - def component_path(self): - """Component definition path.""" - component_definition = self.component_info["Info"] - component_data = self._circuit_components.o_component_manager.GetData(component_definition) - if not component_data: - self._circuit_components._app.logger.warning("Component " + self.refdes + " has no path") - return False - if len(component_data[2][5]) == 0: - for data in component_data: - if isinstance(data, list) and isinstance(data[0], str) and data[0] == "NAME:CosimDefinitions": - return (data[1][12][1].split(" ")[1])[1:-1] - else: - return component_data[2][5] - @property def component_path(self): """Component definition path."""