Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
141 commits
Select commit Hold shift + click to select a range
935d091
EMIT API branch
jsalant22 Jan 22, 2025
f14755b
Add first draft of generated nodes and basic interface
bryankaylor Jan 28, 2025
4aef45e
New version of generated nodes
bryankaylor Jan 31, 2025
3cce1c1
Updated generated nodes and interface
bryankaylor Feb 1, 2025
04c4218
Add generated module init file, update EmitNode
bryankaylor Feb 4, 2025
3f33e2a
Add node functions for getting children
bryankaylor Feb 5, 2025
bfef0cf
Update generated nodes spacing and add_ methods, move NodeInterface m…
bryankaylor Feb 11, 2025
3aac82f
Add equality operator to EmitNode class
bryankaylor Feb 14, 2025
70100fd
Remove equality operator from generated nodes
bryankaylor Feb 14, 2025
84f6c32
update revision and result classes for api changes
jsalant22 Feb 14, 2025
5d0ece1
Merge branch 'F932911' of https://github.com/ansys/pyaedt into F932911
jsalant22 Feb 14, 2025
68034da
use display names for access nodes
jsalant22 Feb 24, 2025
fcee90c
add units support
jsalant22 Feb 26, 2025
c280da2
fix unit parsing
jsalant22 Feb 28, 2025
32060dd
Add updated generated nodes, fix emit allowed unit names, fix emit de…
bryankaylor Mar 4, 2025
6a06ab5
Fix revision constructor for 252, fix units
bryankaylor Mar 13, 2025
5501be5
Update results and revision modules to use new result API
bryankaylor Mar 24, 2025
0633784
Revert change of GetKeptResultProperties to GetResultProperties
bryankaylor Mar 24, 2025
f5b5780
Add EmitterBand and TxSpectralProfEmitter classes (#6048)
jsalant22 Apr 15, 2025
5a01894
Add test for generated nodes
bryankaylor Apr 16, 2025
55bb89d
Fix merge conflict
bryankaylor Apr 16, 2025
726e6d4
Add warning for disconnected comps (#6056)
jsalant22 Apr 21, 2025
4b68e24
F1251272 (#6063)
jsalant22 Apr 21, 2025
95189be
Add dynamic generated node test
bryankaylor Apr 21, 2025
39fd586
Fix conflict
bryankaylor Apr 21, 2025
98d0248
Fix merge conflicts for files deleted in main
bryankaylor Apr 22, 2025
5fba8f8
CHORE: Auto fixes from pre-commit hooks
pre-commit-ci[bot] Apr 22, 2025
4c74e09
chore: adding changelog file 6068.added.md [dependabot-skip]
pyansys-ci-bot Apr 22, 2025
16d567f
Re-delete readded files
bryankaylor Apr 22, 2025
05e89d9
Merge branch 'F932911' of ssh://ssh.github.com:443/ansys/pyaedt into …
bryankaylor Apr 22, 2025
69224b2
Remove unused TestClass member
bryankaylor Apr 22, 2025
d3aa753
Fix duplicate method in EmitNode, change dynamic test to run all methods
bryankaylor Apr 22, 2025
c0da9c1
CHORE: Auto fixes from pre-commit hooks
pre-commit-ci[bot] Apr 22, 2025
80138a3
Support loading Kept results, return ReadOnly nodes for Kept results,…
bryankaylor Apr 23, 2025
1a57448
Merge branch 'F932911' of ssh://ssh.github.com:443/ansys/pyaedt into …
bryankaylor Apr 23, 2025
a9f347d
CHORE: Auto fixes from pre-commit hooks
pre-commit-ci[bot] Apr 23, 2025
f173855
Merge branch 'main' into F932911
jsalant22 Apr 23, 2025
393bb29
style changes
jsalant22 Apr 23, 2025
fdf0c3f
CHORE: Auto fixes from pre-commit hooks
pre-commit-ci[bot] Apr 23, 2025
df07da7
more style fixes
jsalant22 Apr 23, 2025
e3faed0
CHORE: Auto fixes from pre-commit hooks
pre-commit-ci[bot] Apr 23, 2025
ca0c268
add enum imports
jsalant22 Apr 23, 2025
b7e4e8f
Merge branch 'F932911' of https://github.com/ansys/pyaedt into F932911
jsalant22 Apr 23, 2025
420ed94
CHORE: Auto fixes from pre-commit hooks
pre-commit-ci[bot] Apr 23, 2025
b21517c
use pyaedt decorator
jsalant22 Apr 23, 2025
2ee9f3f
Merge branch 'F932911' of https://github.com/ansys/pyaedt into F932911
jsalant22 Apr 23, 2025
f86bdd1
CHORE: Auto fixes from pre-commit hooks
pre-commit-ci[bot] Apr 23, 2025
b28c667
style fixes
jsalant22 Apr 23, 2025
5d43d9a
CHORE: Auto fixes from pre-commit hooks
pre-commit-ci[bot] Apr 23, 2025
3a1485e
fix method names
jsalant22 Apr 23, 2025
b4d064c
CHORE: Auto fixes from pre-commit hooks
pre-commit-ci[bot] Apr 23, 2025
a552d44
revert min version check
jsalant22 Apr 23, 2025
7e0158b
CHORE: Auto fixes from pre-commit hooks
pre-commit-ci[bot] Apr 23, 2025
358dbc8
move decorator out of class
jsalant22 Apr 23, 2025
b967b2f
remove unused import
jsalant22 Apr 23, 2025
fa4f58b
CHORE: Auto fixes from pre-commit hooks
pre-commit-ci[bot] Apr 23, 2025
6d1ed2d
fix some units code
jsalant22 Apr 24, 2025
7dd7750
CHORE: Auto fixes from pre-commit hooks
pre-commit-ci[bot] Apr 24, 2025
a829dc8
skip lint
jsalant22 Apr 24, 2025
d146173
replace id with node_id
jsalant22 Apr 24, 2025
0d71e22
CHORE: Auto fixes from pre-commit hooks
pre-commit-ci[bot] Apr 24, 2025
e37b217
change solver to use 25.2
jsalant22 Apr 24, 2025
a0f00d9
chore: adding changelog file 6068.added.md [dependabot-skip]
pyansys-ci-bot Apr 24, 2025
1f11dcc
Merge branch 'main' into F932911
jsalant22 Apr 24, 2025
a3e5e87
Support component rename in EmitNode.rename, update all generated cla…
bryankaylor Apr 24, 2025
cfc3001
Merge branch 'F932911' of ssh://ssh.github.com:443/ansys/pyaedt into …
bryankaylor Apr 24, 2025
faf5ea8
CHORE: Auto fixes from pre-commit hooks
pre-commit-ci[bot] Apr 24, 2025
6e98c38
Remove some unused topLevelNode access
jsalant22 May 9, 2025
bb8e556
Update revision.py
jsalant22 May 9, 2025
ab349b3
CHORE: Auto fixes from pre-commit hooks
pre-commit-ci[bot] May 9, 2025
9759502
Fix EMIT tests for 252
bryankaylor May 9, 2025
6582562
Merge branch 'F932911' of ssh://ssh.github.com:443/ansys/pyaedt into …
bryankaylor May 12, 2025
6c766ff
CHORE: Auto fixes from pre-commit hooks
pre-commit-ci[bot] May 12, 2025
901d7f0
Reuse current result, remove irrelevant block from revision generatio…
bryankaylor May 15, 2025
a494595
Fix 25R1 tests
bryankaylor May 15, 2025
087da75
Re-add get/set units to EMIT object
bryankaylor May 15, 2025
0e7bec6
CHORE: Auto fixes from pre-commit hooks
pre-commit-ci[bot] May 15, 2025
ca9dae1
Fix version check in Enum initialization
bryankaylor May 19, 2025
0c0a481
Merge branch 'main' into F932911
SMoraisAnsys May 21, 2025
c2d6b33
CHORE: Add nosec B105 where needed
SMoraisAnsys May 21, 2025
e8b675c
address PR comments
jsalant22 May 21, 2025
75dbed9
CHORE: Auto fixes from pre-commit hooks
pre-commit-ci[bot] May 21, 2025
ca17091
remove lint comments
jsalant22 May 21, 2025
42b3098
CHORE: Auto fixes from pre-commit hooks
pre-commit-ci[bot] May 21, 2025
2f03278
Use absolute imports, use common AEDT major version guard decorator, …
bryankaylor May 21, 2025
17c3fe2
Remove test file
bryankaylor May 21, 2025
72efa75
CHORE: Auto fixes from pre-commit hooks
pre-commit-ci[bot] May 21, 2025
dcb38aa
Update src/ansys/aedt/core/emit_core/emit_constants.py
bryankaylor May 21, 2025
a30cbbb
Fix all docstrings in generated EMIT classes
bryankaylor May 30, 2025
ec05d69
Fix power unit in radio_component test
bryankaylor May 30, 2025
6b1ba5a
Initial commit
ramin4667 Jun 9, 2025
cfbd191
chore: adding changelog file 6249.added.md [dependabot-skip]
pyansys-ci-bot Jun 9, 2025
6e749c8
CHORE: Auto fixes from pre-commit hooks
pre-commit-ci[bot] Jun 9, 2025
af1b65d
updating to return Emit node instead of ID
ramin4667 Jun 10, 2025
a1fe8f6
Merge branch 'emit_schematic_feature' of https://github.com/ansys/pya…
ramin4667 Jun 10, 2025
2a1ac4f
update bool get/set
jsalant22 Jun 11, 2025
f1f68ff
Merge remote-tracking branch 'origin/F932911' into emit_schematic_fea…
ramin4667 Jun 13, 2025
0726357
id is replaced by comp_id
ramin4667 Jun 13, 2025
e1b5f4d
true value correction
ramin4667 Jun 13, 2025
66c72cf
id replacement with comp_id
ramin4667 Jun 13, 2025
5840e0a
more id replacement with comp_id
ramin4667 Jun 13, 2025
64534d6
Initial commit
ramin4667 Jun 23, 2025
2972e9f
chore: adding changelog file 6300.added.md [dependabot-skip]
pyansys-ci-bot Jun 23, 2025
0671aa7
Reorientation property added.
ramin4667 Jun 25, 2025
f336923
Merge branch 'ability_to_connect_components' of https://github.com/an…
ramin4667 Jun 25, 2025
33aff77
Orientation property updated.
ramin4667 Jun 26, 2025
ffc6350
Update docstring parsing for min/max, use EmitNode._get_property and …
bryankaylor Jun 27, 2025
e6dfc24
Merge branch 'F932911' of https://github.com/ansys/pyaedt into F932911
bryankaylor Jun 27, 2025
a47aa15
Call each node property for multiple configurations of each node, fix…
bryankaylor Jul 11, 2025
8719175
Comment out testing of kept result nodes
bryankaylor Jul 11, 2025
0242871
Remove read_only versions of nodes, and stop constructing them
bryankaylor Jul 11, 2025
050b945
Merge branch 'main' into F932911
bryankaylor Jul 14, 2025
b25d529
chore: adding changelog file 6068.added.md [dependabot-skip]
pyansys-ci-bot Jul 14, 2025
2bc73f5
CHORE: Auto fixes from pre-commit hooks
pre-commit-ci[bot] Jul 14, 2025
25ddd62
Not skip test in 2025R2
Samuelopez-ansys Jul 15, 2025
36535fe
Test both getter and setter if setter fails
bryankaylor Jul 15, 2025
247fec4
Merge branch 'F932911' of https://github.com/ansys/pyaedt into F932911
bryankaylor Jul 15, 2025
297be00
CHORE: Auto fixes from pre-commit hooks
pre-commit-ci[bot] Jul 15, 2025
5db53c8
Fix units, dont skip test 23b
bryankaylor Jul 15, 2025
80f48f3
Merge branch 'F932911' of https://github.com/ansys/pyaedt into F932911
bryankaylor Jul 15, 2025
ecf7111
Fix all codacy issues
bryankaylor Jul 15, 2025
1ca0c8b
CHORE: Auto fixes from pre-commit hooks
pre-commit-ci[bot] Jul 15, 2025
c923dac
Remove duplicate result cat test
bryankaylor Jul 16, 2025
93cdf48
Renumber test, record exceptions when adding child nodes
bryankaylor Jul 16, 2025
6dc02fb
Merge branch 'F932911' of https://github.com/ansys/pyaedt into F932911
bryankaylor Jul 16, 2025
929ac5c
CHORE: Auto fixes from pre-commit hooks
pre-commit-ci[bot] Jul 16, 2025
5f86428
Merge branch 'main' into F932911
Samuelopez-ansys Jul 17, 2025
ebe07c1
Merge branch 'main' into F932911
Samuelopez-ansys Jul 19, 2025
bbf9314
Fix pre-commit
Samuelopez-ansys Jul 19, 2025
432c91d
Fix documentation
Samuelopez-ansys Jul 19, 2025
afbc02a
Revert default version
Samuelopez-ansys Jul 19, 2025
eab3558
Merge branch 'main' into F932911
Samuelopez-ansys Jul 19, 2025
db91df0
Merge F932911 into ability_to_connect_components
bryankaylor Jul 21, 2025
a4ccb16
CHORE: Auto fixes from pre-commit hooks
pre-commit-ci[bot] Jul 21, 2025
243e7e5
Update current revision constructor comments
bryankaylor Jul 21, 2025
e091650
Revert "Update current revision constructor comments"
bryankaylor Jul 21, 2025
1c777ad
Merge branch 'main' into ability_to_connect_components
bryankaylor Jul 22, 2025
58d1242
Update src/ansys/aedt/core/modeler/circuits/primitives_circuit.py
jsalant22 Jul 25, 2025
f2bb4c3
Update primitives_circuit.py
jsalant22 Jul 25, 2025
bf43ff7
Merge branch 'main' into ability_to_connect_components
jsalant22 Jul 25, 2025
2524063
Merge branch 'main' into ability_to_connect_components
jsalant22 Aug 6, 2025
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
1 change: 1 addition & 0 deletions doc/changelog.d/6249.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
emit_schematic_feature
1 change: 1 addition & 0 deletions doc/changelog.d/6300.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ability to connect components
13 changes: 13 additions & 0 deletions src/ansys/aedt/core/emit.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from ansys.aedt.core.emit_core.couplings import CouplingsEmit
from ansys.aedt.core.emit_core.emit_constants import EMIT_VALID_UNITS
from ansys.aedt.core.emit_core.emit_constants import emit_unit_type_string_to_enum
from ansys.aedt.core.emit_core.emit_schematic import EmitSchematic
from ansys.aedt.core.emit_core.results.results import Results
from ansys.aedt.core.generic.general_methods import pyaedt_function_handler
from ansys.aedt.core.modeler.schematic import ModelerEmit
Expand Down Expand Up @@ -172,6 +173,7 @@ def __init__(
)
self._modeler = ModelerEmit(self)
self._couplings = CouplingsEmit(self)
self._schematic = EmitSchematic(self)
if self._aedt_version > "2023.1":
# the next 2 lines of code are needed to point
# the EMIT object to the correct EmiApiPython
Expand Down Expand Up @@ -210,6 +212,17 @@ def couplings(self):
"""
return self._couplings

@property
def schematic(self):
"""EMIT Schematic.

Returns
-------
:class:`ansys.aedt.core.emit_core.emit_schematic.EmitSchematic`
EMIT schematic.
"""
return self._schematic

@pyaedt_function_handler()
def version(self, detailed=False):
"""
Expand Down
292 changes: 292 additions & 0 deletions src/ansys/aedt/core/emit_core/emit_schematic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,292 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2021 - 2025 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.


from ansys.aedt.core.emit_core.nodes.emit_node import EmitNode
from ansys.aedt.core.generic.general_methods import pyaedt_function_handler


class EmitSchematic:
"""Represents the EMIT schematic and provides methods to interact with it."""

def __init__(self, emit_instance):
"""Initialize the EmitSchematic class.

Parameters
----------
emit_instance : Emit
Instance of the Emit class.
"""
self.emit_instance = emit_instance

@property
def _emit_com_module(self):
"""Retrieve the EmitCom module from the Emit instance.

Returns
-------
object
The EmitCom module.

Raises
------
RuntimeError
If the EmitCom module cannot be retrieved.
"""
if not hasattr(self.emit_instance, "_odesign"):
raise RuntimeError("Emit instance does not have a valid '_odesign' attribute.")
try:
return self.emit_instance._odesign.GetModule("EmitCom")
except Exception as e:
raise RuntimeError(f"Failed to retrieve EmitCom module: {e}")

@pyaedt_function_handler
def create_component(self, component_type: str, name: str = None, library: str = None) -> EmitNode:
"""Create a component.

Parameters
----------
component_type : str
Type of the component to create.
name : str, optional
Name of the component to create. AEDT defaults used if not provided.
library : str, optional
Name of the component library. Defaults to an empty string if not provided.

Returns
-------
EmitNode
The EmitNode of the created component.

Raises
------
ValueError
If the component type is empty or no matching component is found.
RuntimeError
If the component creation fails.
"""
if not component_type:
raise ValueError("The 'component_type' argument is required.")

name = name or ""
library = library or ""

try:
# Retrieve matching components from the catalog
matching_components = self.emit_instance.modeler.components.components_catalog[component_type]

if not matching_components:
self.emit_instance.logger.error(f"No component found for type '{component_type}'.")
raise ValueError(f"No component found for type '{component_type}'.")

if len(matching_components) == 1:
# Use the single matching component
component = matching_components[0]
self.emit_instance.logger.info(
f"Using component '{component.name}' from library '{component.component_library}"
f"' for type '{component_type}'."
)
else:
# Attempt to find an exact match
component = next((comp for comp in matching_components if comp.name == component_type), None)
if not component:
self.emit_instance.logger.error(
f"Multiple components found for type '{component_type}', but no exact match."
" Please specify a unique component."
)
raise ValueError(f"Multiple components found for type '{component_type}', but no exact match.")
self.emit_instance.logger.info(
f"Using exact match component '{component.name}' from library '{component.component_library}"
f"' for type '{component_type}'."
)
stripped_component_name = component.name.strip("'")
revision = self.emit_instance.results.get_revision()
# Create the component using the EmitCom module
new_component_id = self._emit_com_module.CreateEmitComponent(
name, stripped_component_name, component.component_library
)

component_node = revision._get_node(node_id=new_component_id)
return component_node
except Exception as e:
self.emit_instance.logger.error(f"Failed to create component '{name}' of type '{component_type}': {e}")
raise RuntimeError(f"Failed to create component of type '{component_type}': {e}")

@pyaedt_function_handler
def create_radio_antenna(
self, radio_type: str, radio_name: str = None, antenna_name: str = None, library: str = None
) -> tuple[EmitNode, EmitNode]:
"""Create a new radio and antenna and connect them.

Parameters
----------
radio_type : str
Type of radio to create. For example, "Bluetooth". Must match
a radio name in the specified library.
radio_name : str, optional
Name to assign to the new radio. If ``None``, then an instance
name is assigned automatically. The default is ``None``.
antenna_name : str, optional
Name to assign to the new antenna. If ``None``, then an instance
name is assigned automatically. The default is ``None``.
library : str, optional
Name of the component library. If ``None``, then the default
library is used. The default is ``None``.

Returns
-------
tuple[EmitNode, EmitNode]
A tuple containing the EmitNode of the created radio and antenna.

Raises
------
RuntimeError
If the radio or antenna creation fails.
"""
radio_name = radio_name or ""
antenna_name = antenna_name or ""
library = library or ""

try:
new_radio = self.create_component(radio_type, radio_name, library)
new_antenna = self.create_component("Antenna", antenna_name, "Antennas")
if new_radio and new_antenna:
self.connect_components(new_antenna, new_radio, "in", "n1") # Connect antenna to radio
return new_radio, new_antenna
except Exception as e:
self.emit_instance.logger.error(f"Failed to create radio of type '{radio_type}' or antenna: {e}")
raise RuntimeError(f"Failed to create radio of type '{radio_type}' or antenna: {e}")

@pyaedt_function_handler
def connect_components(
self, component_1: EmitNode, component_2: EmitNode, component_port_1: str = None, component_port_2: str = None
) -> None:
"""Connect two components in the schematic.

Parameters
----------
component_1 : EmitNode
First component to connect.
component_2 : EmitNode
Second component to connect.
component_port_1 : str, optional
Port of the first component to connect. If ``None``, the default port is used.
component_port_2 : str, optional
Port of the second component to connect. If ``None``, the default port is used.

Raises
------
RuntimeError
If the connection fails.
"""
try:
component_port_1 = component_port_1 or "n1"
component_port_2 = component_port_2 or "n2"
# Update the component ports to match the emit definition
component_port_1 = self._component_port_update(component_port_1)
component_port_2 = self._component_port_update(component_port_2)
# Get the ports and their locations for both components
ports_1 = self.emit_instance._oeditor.GetComponentPorts(component_1.name)
port_locs_1 = {
port: self.emit_instance._oeditor.GetComponentPortLocation(component_1.name, port) for port in ports_1
}
if len(ports_1) == 1:
component_port_1 = ports_1[0]
if component_1.properties["Type"] == "Multiplexer":
component_port_1 = component_port_1.strip("n")

ports_2 = self.emit_instance._oeditor.GetComponentPorts(component_2.name)
port_locs_2 = {
port: self.emit_instance._oeditor.GetComponentPortLocation(component_2.name, port) for port in ports_2
}
if len(ports_2) == 1:
component_port_2 = ports_2[0]
if component_2.properties["Type"] == "Multiplexer":
component_port_2 = component_port_2.strip("n")

# Validate that the specified ports exist in their respective components
if component_port_1 not in port_locs_1:
raise ValueError(f"Port '{component_port_1}' does not exist in component '{component_1.name}'.")
if component_port_2 not in port_locs_2:
raise ValueError(f"Port '{component_port_2}' does not exist in component '{component_2.name}'.")
# Check if the ports are on the same side of the components
component_1_antenna_pors_list = [x for x in component_1.properties["AntennaSidePorts"].split("|")]
component_1_radio_ports_list = [x for x in component_1.properties["RadioSidePorts"].split("|")]
if component_1.properties["Type"] == "AntennaNode":
component_1_radio_ports_list = ["n"]
if component_1.properties["Type"] == "RadioNode":
component_1_antenna_pors_list = ["1"]
component_2_antenna_ports_list = [x for x in component_2.properties["AntennaSidePorts"].split("|")]
component_2_radio_ports_list = [x for x in component_2.properties["RadioSidePorts"].split("|")]
if component_2.properties["Type"] == "AntennaNode":
component_2_radio_ports_list = ["n"]
if component_2.properties["Type"] == "RadioNode":
component_2_antenna_ports_list = ["1"]

if (
component_port_1[-1] in component_1_antenna_pors_list
and component_port_2[-1] in component_2_antenna_ports_list
) or (
component_port_1[-1] in component_1_radio_ports_list
and component_port_2[-1] in component_2_radio_ports_list
):
raise RuntimeError("Both ports are on the same side. Connection cannot be established.")
# Move the first component to align with the second component's port
delta_x = port_locs_2[component_port_2][0] - port_locs_1[component_port_1][0]
delta_y = port_locs_2[component_port_2][1] - port_locs_1[component_port_1][1]
self.emit_instance._oeditor.Move(component_1.name, delta_x, delta_y)
self.emit_instance.logger.info(
f"Successfully connected components '{component_1.name}' and '{component_2.name}'."
)
except Exception as e:
self.emit_instance.logger.error(
f"Failed to connect components '{component_1.name}' and '{component_2.name}' with the given ports: {e}"
)
raise RuntimeError(
f"Failed to connect components '{component_1.name}' and '{component_2.name}' with the given ports: {e}"
)

@pyaedt_function_handler
def _component_port_update(self, input_port: str) -> str:
"""Update the component port properties as emit definition.

Parameters
----------
input_port : str
Name of the input port to update.

Returns
-------
updated_port: int
The updated port number after the update.
"""

port_number = input_port[-1]
if port_number in ["2", "3", "4", "5", "6"]:
updated_port = "n" + port_number
elif port_number in ["1", "n"]:
updated_port = "n1"
else:
raise ValueError(f"Invalid port format: '{input_port}'")
return updated_port
36 changes: 36 additions & 0 deletions src/ansys/aedt/core/emit_core/nodes/emit_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,3 +471,39 @@ def _add_child_node(self, child_type, child_name=None):
except Exception as e:
print(f"Failed to add child node of type {child_type} to node {self.name}. Error: {e}")
return new_id

@property
def orientation(self) -> int:
"""Returns the orientation of the component.

Returns:
int: The orientation of the component, where valid values range from 0 to 3.
"""
return self._emit_obj.oeditor.GetComponentOrientation(self.name)

@orientation.setter
def orientation(self, value: int) -> None:
if self.properties["Type"] != "Multiplexer" and value not in [0, 1]:
raise ValueError(f"Orientation must be either 0 or 1 for component '{self.name}'.")
elif self.properties["Type"] == "Multiplexer" and value not in [0, 1, 2, 3]:
raise ValueError("Orientation must be one of the following: 0, 1, 2, or 3 for Multiplexer components.")
if self.orintation_count > 1:
self._emit_obj.oeditor.ReorientComponent(self.name, value)
self._emit_obj.logger.info(f"Successfully set orientation to {value} for component '{self.name}'.")
else:
error_message = (
f"Orientation adjustment is not supported for component '{self.name}'. "
"This component cannot be reoriented."
)
self._emit_obj.logger.error(error_message)
raise ValueError(error_message)

@property
def orintation_count(self) -> int:
"""Returns the number of orientations available for the component.

Returns:
int: The number of valid orientations. A value of 1 indicates the component cannot be reoriented,
2 indicates support for basic reorientation, and 4 is used for multiplexer components.
"""
return self._emit_obj.oeditor.GetNumComponentOrientations(self.name)
1 change: 0 additions & 1 deletion src/ansys/aedt/core/emit_core/results/revision.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ def __init__(self, parent_results, emit_obj, name=None):

self.name = name
"""Name of the revision."""

else:
if not name:
name = emit_obj.odesign.GetCurrentResult()
Expand Down
Loading
Loading