Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEAT: get the path of a circuit component #5598

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/ansys/aedt/core/modeler/circuits/object_3d_circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -1084,6 +1084,18 @@
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"]
if not self._circuit_components.o_component_manager.GetData(component_definition):
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]

Check warning on line 1097 in src/ansys/aedt/core/modeler/circuits/object_3d_circuit.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/modeler/circuits/object_3d_circuit.py#L1090-L1097

Added lines #L1090 - L1097 were not covered by tests


class Wire(object):
"""Creates and manipulates a wire."""
Expand Down
7 changes: 7 additions & 0 deletions tests/system/general/test_21_Circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -1011,3 +1011,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
Loading