Skip to content

Commit

Permalink
FIX: Modified return statement for sweep_around_axis and sweep_along_…
Browse files Browse the repository at this point in the history
…path so methods accept lists without creating error messages in AEDT. (#5416)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
DaveTwyman and pre-commit-ci[bot] authored Nov 22, 2024
1 parent 5b682d0 commit 91543ea
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 17 deletions.
22 changes: 17 additions & 5 deletions src/ansys/aedt/core/modeler/cad/primitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -3156,10 +3156,10 @@ def sweep_along_vector(self, assignment, sweep_vector, draft_angle=0, draft_type
self.oeditor.SweepAlongVector(vArg1, vArg2)

if isinstance(assignment, list):
updated_obj = []
res = []
for sel_obj in assignment:
updated_obj.append(self.update_object(sel_obj))
return updated_obj
res.append(self.update_object(sel_obj))
return res
else:
return self.update_object(assignment)

Expand Down Expand Up @@ -3211,7 +3211,13 @@ def sweep_along_path(

self.oeditor.SweepAlongPath(vArg1, vArg2)

return self.update_object(assignment)
if isinstance(assignment, list):
res = []
for sel_obj in assignment:
res.append(self.update_object(sel_obj))
return res
else:
return self.update_object(assignment)

@pyaedt_function_handler(objid="assignment", cs_axis="axis")
def sweep_around_axis(self, assignment, axis, sweep_angle=360, draft_angle=0, number_of_segments=0):
Expand Down Expand Up @@ -3261,7 +3267,13 @@ def sweep_around_axis(self, assignment, axis, sweep_angle=360, draft_angle=0, nu

self.oeditor.SweepAroundAxis(vArg1, vArg2)

return self.update_object(assignment)
if isinstance(assignment, list):
res = []
for sel_obj in assignment:
res.append(self.update_object(sel_obj))
return res
else:
return self.update_object(assignment)

@pyaedt_function_handler(object_list="assignment")
def section(self, assignment, plane, create_new=True, section_cross_object=False):
Expand Down
48 changes: 36 additions & 12 deletions tests/system/general/test_08_Primitives3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,21 +475,27 @@ def test_21_sweep_along_path(self):
udp2 = [5, 0, 0]
udp3 = [5, 5, 0]
arrofpos = [udp1, udp2, udp3]
path = self.aedtapp.modeler.create_polyline(arrofpos, name="poly_vector")
my_name = path.name
assert my_name in self.aedtapp.modeler.line_names
assert my_name in self.aedtapp.modeler.model_objects
assert my_name in self.aedtapp.modeler.object_names
assert isinstance(self.aedtapp.modeler.get_vertices_of_line(my_name), list)
rect = self.aedtapp.modeler.create_rectangle(self.aedtapp.PLANE.YZ, [0, -2, -2], [4, 3], name="rect_1")
swept = self.aedtapp.modeler.sweep_along_path(rect, path)
assert swept
assert rect.name in self.aedtapp.modeler.solid_names
path1 = self.aedtapp.modeler.create_polyline(arrofpos, name="poly_vector1")
path2 = self.aedtapp.modeler.create_polyline(arrofpos, name="poly_vector2")

rect1 = self.aedtapp.modeler.create_rectangle(self.aedtapp.PLANE.YZ, [0, -2, -4], [4, 3], name="rect_1")
rect2 = self.aedtapp.modeler.create_rectangle(self.aedtapp.PLANE.YZ, [0, -2, 2], [4, 3], name="rect_2")
rect3 = self.aedtapp.modeler.create_rectangle(self.aedtapp.PLANE.YZ, [0, -2, 8], [4, 3], name="rect_3")
assert self.aedtapp.modeler.sweep_along_path(rect1, path1)
assert self.aedtapp.modeler.sweep_along_path([rect2, rect3], path2)
assert rect1.name in self.aedtapp.modeler.solid_names
assert rect2.name in self.aedtapp.modeler.solid_names
assert rect3.name in self.aedtapp.modeler.solid_names

def test_22_sweep_along_vector(self):
rect2 = self.aedtapp.modeler.create_rectangle(self.aedtapp.PLANE.YZ, [0, -2, -2], [4, 3], name="rect_2")
assert self.aedtapp.modeler.sweep_along_vector(rect2, [10, 20, 20])
rect1 = self.aedtapp.modeler.create_rectangle(self.aedtapp.PLANE.YZ, [0, -2, -2], [4, 3], name="rect_1")
rect2 = self.aedtapp.modeler.create_rectangle(self.aedtapp.PLANE.YZ, [0, -2, 2], [4, 3], name="rect_2")
rect3 = self.aedtapp.modeler.create_rectangle(self.aedtapp.PLANE.YZ, [0, -2, 4], [4, 3], name="rect_3")
assert self.aedtapp.modeler.sweep_along_vector(rect1, [10, 20, 20])
assert self.aedtapp.modeler.sweep_along_vector([rect2, rect3], [10, 20, 20])
assert rect1.name in self.aedtapp.modeler.solid_names
assert rect2.name in self.aedtapp.modeler.solid_names
assert rect3.name in self.aedtapp.modeler.solid_names

def test_23_create_rectangle(self):
udp = self.aedtapp.modeler.Position(5, 3, 8)
Expand Down Expand Up @@ -2074,3 +2080,21 @@ def test_95_update_geometry_property(self):

self.aedtapp.modeler.update_geometry_property([box1.name, box2.name], "material_appearance", True)
assert box2.material_appearance

def test_96_sweep_around_axis(self):
circle1 = self.aedtapp.modeler.create_circle(
orientation="Z", origin=[5, 0, 0], radius=2, num_sides=8, name="circle1"
)
circle2 = self.aedtapp.modeler.create_circle(
orientation="Z", origin=[15, 0, 0], radius=2, num_sides=8, name="circle2"
)
circle3 = self.aedtapp.modeler.create_circle(
orientation="Z", origin=[25, 0, 0], radius=2, num_sides=8, name="circle3"
)

assert self.aedtapp.modeler.sweep_around_axis(assignment=circle1, axis="Z")
assert self.aedtapp.modeler.sweep_around_axis(assignment=[circle2, circle3], axis="Z")

assert circle1.name in self.aedtapp.modeler.solid_names
assert circle2.name in self.aedtapp.modeler.solid_names
assert circle3.name in self.aedtapp.modeler.solid_names

0 comments on commit 91543ea

Please sign in to comment.