Skip to content

Commit 0671aa7

Browse files
committed
Reorientation property added.
1 parent 64534d6 commit 0671aa7

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

src/ansys/aedt/core/emit_core/emit_schematic.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,15 @@ def connect_components(
235235
component_1_radio_ports_list = [x for x in component_1.properties["RadioSidePorts"].split("|")]
236236
if component_1.properties["Type"] == "AntennaNode":
237237
component_1_radio_ports_list = ["n"]
238+
if component_1.properties["Type"] == "RadioNode":
239+
component_1_antenna_pors_list = ["1"]
238240
component_2_antenna_ports_list = [x for x in component_2.properties["AntennaSidePorts"].split("|")]
239241
component_2_radio_ports_list = [x for x in component_2.properties["RadioSidePorts"].split("|")]
240242
if component_2.properties["Type"] == "AntennaNode":
241243
component_2_radio_ports_list = ["n"]
244+
if component_2.properties["Type"] == "RadioNode":
245+
component_2_antenna_ports_list = ["1"]
246+
242247
if (
243248
component_port_1[-1] in component_1_antenna_pors_list
244249
and component_port_2[-1] in component_2_antenna_ports_list

src/ansys/aedt/core/emit_core/nodes/emit_node.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def _parent(self):
9090

9191
@property
9292
def properties(self):
93-
"""Get's the node's properties.
93+
"""Gets the node's properties.
9494
9595
Returns:
9696
Dict: dictionary of the node's properties. The display name
@@ -404,3 +404,26 @@ def _add_child_node(self, child_type, child_name=None):
404404
except Exception as e:
405405
print(f"Failed to add child node of type {child_type} to node {self.name}. Error: {e}")
406406
return new_id
407+
408+
@property
409+
def reorient(self) -> None:
410+
"""Reorient an emit node in the schematic.
411+
412+
Returns:
413+
int: The new orientation of the component (0 or 1).
414+
415+
Raises:
416+
RuntimeError: If the component does not support orientation.
417+
"""
418+
try:
419+
orientation = self._emit_obj.oeditor.GetComponentOrientation(self.name)
420+
new_orientation = 1 - orientation
421+
self._emit_obj.oeditor.ReorientComponent(self.name, new_orientation)
422+
self._emit_obj.logger.info(f"Successfully reoriented component '{self.name}'.")
423+
except Exception as e:
424+
error_message = (
425+
f"Reorientation failed; orientation adjustment is not supported "
426+
f"for component '{self.name}'. Error: {e}"
427+
)
428+
self._emit_obj.logger.error(error_message)
429+
raise RuntimeError(error_message)

tests/system/solvers/test_26_emit.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1679,3 +1679,20 @@ def test_30_connect_components(self, add_app):
16791679
assert (
16801680
"Failed to connect components 'MICS' and 'Antenna' with the given ports: Invalid port format: 'wrongport'"
16811681
) in str(e.value)
1682+
1683+
@pytest.mark.skipif(config["desktopVersion"] < "2025.2", reason="Skipped on versions earlier than 2025 R2.")
1684+
def test_31_reorient_component(self, add_app):
1685+
self.aedtapp = add_app(project_name="reorient_component", application=Emit)
1686+
new_circulator = self.aedtapp.schematic.create_component("Circulator")
1687+
assert ["2", "3"] == [x for x in new_circulator.properties["AntennaSidePorts"].split("|")]
1688+
assert ["1"] == [x for x in new_circulator.properties["RadioSidePorts"].split("|")]
1689+
new_circulator.reorient
1690+
assert ["1"] == [x for x in new_circulator.properties["AntennaSidePorts"].split("|")]
1691+
assert ["3", "2"] == [x for x in new_circulator.properties["RadioSidePorts"].split("|")]
1692+
with pytest.raises(RuntimeError) as e:
1693+
new_radio = self.aedtapp.schematic.create_component("New Radio")
1694+
new_radio.reorient
1695+
assert (
1696+
"Reorientation failed; orientation adjustment is not supported for component 'Radio'. "
1697+
"Error: Failed to execute gRPC AEDT command: ReorientComponent"
1698+
) in str(e.value)

0 commit comments

Comments
 (0)