Skip to content
Merged
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
1 change: 1 addition & 0 deletions doc/changelog.d/6804.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allow Object3d to be used in create_current_source_from_objects
22 changes: 11 additions & 11 deletions src/ansys/aedt/core/modeler/cad/primitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ def model_consistency_report(self):
return report

@property
def objects_by_name(self):
def objects_by_name(self) -> dict[str, Object3d]:
"""Object dictionary organized by name.

Returns
Expand Down Expand Up @@ -6587,26 +6587,26 @@ def value_in_object_units(self, value):
return numeric_list

@pyaedt_function_handler(obj_to_check="assignment")
def does_object_exists(self, assignment):
def does_object_exists(self, assignment) -> bool:
"""Check to see if an object exists.

Parameters
----------
assignment : str, int
Object name or object ID.
assignment : str, int or :class:`ansys.aedt.core.modeler.cad.object_3d.Object3d`
Object name or object ID or Object3d to check.

Returns
-------
bool
``True`` when successful, ``False`` when failed.

"""
if isinstance(assignment, int) and assignment in self.objects:
return True
elif assignment in self.objects_by_name:
return True
else:
return False
if isinstance(assignment, int):
return assignment in self.objects
elif isinstance(assignment, str):
return assignment in self.objects_by_name
elif isinstance(assignment, Object3d):
return assignment.name in self.objects_by_name
return False

@pyaedt_function_handler(parts="assignment", region_name="name")
def create_subregion(self, padding_values, padding_types, assignment, name=None):
Expand Down
6 changes: 5 additions & 1 deletion src/ansys/aedt/core/modeler/cad/primitives_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from math import tan
import os
from pathlib import Path
from typing import TYPE_CHECKING

from ansys.aedt.core import Edb
from ansys.aedt.core.base import PyAedtBase
Expand All @@ -53,6 +54,9 @@
from ansys.aedt.core.modeler.cad.primitives import GeometryModeler
from ansys.aedt.core.modeler.geometry_operators import GeometryOperators

if TYPE_CHECKING:
from ansys.aedt.core.modeler.cad.object_3d import Object3d


class Primitives3D(GeometryModeler, PyAedtBase):
"""Manages primitives in applications using the 3D modeler.
Expand Down Expand Up @@ -111,7 +115,7 @@ def __init__(self, application):
self.multiparts = []

@pyaedt_function_handler(position="origin", dimensions_list="sizes", matname="material")
def create_box(self, origin, sizes, name=None, material=None, **kwargs):
def create_box(self, origin, sizes, name=None, material=None, **kwargs) -> "Object3d":
"""Create a box.

Parameters
Expand Down
15 changes: 13 additions & 2 deletions tests/system/general/test_20_HFSS.py
Original file line number Diff line number Diff line change
Expand Up @@ -787,13 +787,24 @@ def test_17B_update_assignment(self):

def test_18_create_sources_on_objects(self):
box1 = self.aedtapp.modeler.create_box([30, 0, 0], [40, 10, 5], "BoxVolt1", "Copper")
self.aedtapp.modeler.create_box([30, 0, 10], [40, 10, 5], "BoxVolt2", "Copper")
box2 = self.aedtapp.modeler.create_box([30, 0, 10], [40, 10, 5], "BoxVolt2", "Copper")
port = self.aedtapp.create_voltage_source_from_objects(
box1.name, "BoxVolt2", self.aedtapp.AxisDir.XNeg, "Volt1"
)
assert port.name in self.aedtapp.excitation_names
port = self.aedtapp.create_current_source_from_objects("BoxVolt1", "BoxVolt2", self.aedtapp.AxisDir.XPos)

# Create with name
port = self.aedtapp.create_current_source_from_objects(box1.name, box2.name, self.aedtapp.AxisDir.XPos)
assert port
assert port.name in self.aedtapp.excitation_names
# Create with id
port2 = self.aedtapp.create_current_source_from_objects(box1.id, box2.id)
assert port2
assert port2.name in self.aedtapp.excitation_names
# Create with Object3d
port3 = self.aedtapp.create_current_source_from_objects(box1, box2)
assert port3
assert port3.name in self.aedtapp.excitation_names

def test_19_create_lumped_on_sheet(self):
rect = self.aedtapp.modeler.create_rectangle(Plane.XY, [0, 0, 0], [10, 2], name="lump_port", material="Copper")
Expand Down