Skip to content

Commit

Permalink
REFACTOR: Add schematics Page option on create_gnd/create_wire (#5712)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
jvela018 and pre-commit-ci[bot] authored Jan 31, 2025
1 parent a48c752 commit 8b5ad23
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/ansys/aedt/core/modeler/circuits/primitives_circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ def create_page_port(self, name, location=None, angle=0):
return self.components[id]

@pyaedt_function_handler()
def create_gnd(self, location=None, angle=0):
def create_gnd(self, location=None, angle=0, page=1):
"""Create a ground.
Parameters
Expand All @@ -380,6 +380,8 @@ def create_gnd(self, location=None, angle=0):
Position on the X and Y axis. The default is ``None``.
angle : optional
Angle rotation in degrees. The default is ``0``.
page: int, optional
Schematics page number. The default value is ``1``.
Returns
-------
Expand All @@ -398,7 +400,7 @@ def create_gnd(self, location=None, angle=0):
angle = math.pi * angle / 180
name = self.oeditor.CreateGround(
["NAME:GroundProps", "Id:=", id],
["NAME:Attributes", "Page:=", 1, "X:=", xpos, "Y:=", ypos, "Angle:=", angle, "Flip:=", False],
["NAME:Attributes", "Page:=", page, "X:=", xpos, "Y:=", ypos, "Angle:=", angle, "Flip:=", False],
)
id = int(name.split(";")[1])
self.add_id_to_component(id)
Expand Down Expand Up @@ -756,6 +758,7 @@ def create_component(
angle=0,
use_instance_id_netlist=False,
global_netlist_list=None,
page=1,
):
"""Create a component from a library.
Expand Down Expand Up @@ -804,7 +807,7 @@ def create_component(
arg1 = ["NAME:ComponentProps", "Name:=", inst_name, "Id:=", str(id)]
xpos, ypos = self._get_location(location)
angle = math.pi * angle / 180
arg2 = ["NAME:Attributes", "Page:=", 1, "X:=", xpos, "Y:=", ypos, "Angle:=", angle, "Flip:=", False]
arg2 = ["NAME:Attributes", "Page:=", page, "X:=", xpos, "Y:=", ypos, "Angle:=", angle, "Flip:=", False]
id = self.oeditor.CreateComponent(arg1, arg2)
id = int(id.split(";")[1])
# self.refresh_all_ids()
Expand Down Expand Up @@ -1201,7 +1204,7 @@ def create_line(self, points, color=0, width=0):
)

@pyaedt_function_handler(points_array="points", wire_name="name")
def create_wire(self, points, name=""):
def create_wire(self, points, name="", page=1):
"""Create a wire.
Parameters
Expand All @@ -1211,6 +1214,8 @@ def create_wire(self, points, name=""):
``[[x1, y1], [x2, y2], ...]``.
name : str, optional
Name of the wire. Default value is ``""``.
page: int, optional
Schematics page number. The default value is ``1``.
Returns
-------
Expand All @@ -1224,7 +1229,7 @@ def create_wire(self, points, name=""):
points = [str(tuple(self._convert_point_to_meter(i))) for i in points]
wire_id = self.create_unique_id()
arg1 = ["NAME:WireData", "Name:=", name, "Id:=", wire_id, "Points:=", points]
arg2 = ["NAME:Attributes", "Page:=", 1]
arg2 = ["NAME:Attributes", "Page:=", page]
try:
wire_id = self.oeditor.CreateWire(arg1, arg2)
w = Wire(self._modeler, composed_name=wire_id)
Expand Down

0 comments on commit 8b5ad23

Please sign in to comment.