Skip to content

Commit 5addaec

Browse files
jvela018maxcapodi78pyansys-ci-botSamuelopez-ansys
authored
FEAT: Uncover face (#6122)
Co-authored-by: mcapodif <[email protected]> Co-authored-by: pyansys-ci-bot <[email protected]> Co-authored-by: Samuel Lopez <[email protected]>
1 parent ec249f1 commit 5addaec

File tree

3 files changed

+76
-0
lines changed

3 files changed

+76
-0
lines changed

doc/changelog.d/6122.added.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Uncover face

src/ansys/aedt/core/modeler/cad/primitives.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,6 +1481,66 @@ def cover_faces(self, assignment):
14811481
self.oeditor.CoverSurfaces(["NAME:Selections", "Selections:=", obj_to_cover, "NewPartsModelFlag:=", "Model"])
14821482
return True
14831483

1484+
@pyaedt_function_handler()
1485+
def uncover_faces(self, assignment):
1486+
"""Uncover faces.
1487+
1488+
Parameters
1489+
----------
1490+
assignment : list
1491+
Sheet objects to uncover.
1492+
1493+
Returns
1494+
-------
1495+
bool
1496+
``True`` when successful, ``False`` when failed.
1497+
1498+
References
1499+
----------
1500+
>>> oEditor.UncoverFaces
1501+
1502+
Examples
1503+
--------
1504+
>>> from ansys.aedt.core import Maxwell3D
1505+
>>> app = Maxwell3D()
1506+
>>> circle_1 = app.modeler.create_circle(cs_plane=0, position=[0, 0, 0], radius=3, name="Circle1")
1507+
>>> box_1 = app.modeler.create_box(origin=[-13.9 ,0 ,0],sizes=[27.8,-40,25.4], name="Box1")
1508+
>>> app.modeler.uncover_faces([circle_1.faces[0], [box_1.faces[0], box_1.faces[2]]])
1509+
"""
1510+
1511+
faces = {}
1512+
flat_assignment = []
1513+
1514+
# create a flat list from assignment
1515+
for item in assignment:
1516+
if isinstance(item, list):
1517+
flat_assignment.extend(item)
1518+
else:
1519+
flat_assignment.append(item)
1520+
1521+
# loop through each item in the flattened list and create a dictionary
1522+
# associating object names to the face ids of faces to be uncovered
1523+
for fid in flat_assignment:
1524+
face_id = int(self.convert_to_selections(fid, False))
1525+
if fid.name not in faces.keys():
1526+
faces[fid.name] = [face_id]
1527+
elif fid.name in faces.keys():
1528+
faces[fid.name].append(face_id)
1529+
1530+
# create variables used in the native api in the right format
1531+
# for selections a concatenated string and for faces_to_uncover a list of int
1532+
selections = ", ".join(str(x) for x in faces.keys())
1533+
faces_to_uncover = []
1534+
for key in faces.keys():
1535+
faces_to_uncover.append(["NAME:UncoverFacesParameters", "FacesToUncover:=", faces[key]])
1536+
# call native api to uncover assigned faces
1537+
self.oeditor.UncoverFaces(
1538+
["NAME:Selections", "Selections:=", selections, "NewPartsModelFlag:=", "Model"],
1539+
["NAME:Parameters", *faces_to_uncover],
1540+
)
1541+
1542+
return True
1543+
14841544
@pyaedt_function_handler()
14851545
def create_coordinate_system(
14861546
self,

tests/system/general/test_08_Primitives3D.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2110,3 +2110,18 @@ def test_96_sweep_around_axis(self):
21102110
assert circle1.name in self.aedtapp.modeler.solid_names
21112111
assert circle2.name in self.aedtapp.modeler.solid_names
21122112
assert circle3.name in self.aedtapp.modeler.solid_names
2113+
2114+
def test_97_uncover_faces(self):
2115+
o1 = self.aedtapp.modeler.create_circle(cs_plane=0, position=[0, 0, 0], radius=10)
2116+
assert self.aedtapp.modeler.uncover_faces([o1.faces[0]])
2117+
c1 = self.aedtapp.modeler.create_circle(orientation=AXIS.X, origin=[0, 10, 20], radius="3", name="Circle1")
2118+
b1 = self.aedtapp.modeler.create_box(origin=[-13.9, 0, 0], sizes=[27.8, -40, 25.4], name="Box1")
2119+
assert self.aedtapp.modeler.uncover_faces([c1.faces[0], b1.faces[0], b1.faces[2]])
2120+
assert len(b1.faces) == 4
2121+
c2 = self.aedtapp.modeler.create_circle(orientation=AXIS.X, origin=[0, 10, 20], radius="3", name="Circle2")
2122+
b2 = self.aedtapp.modeler.create_box(origin=[-13.9, 0, 0], sizes=[27.8, -40, 25.4], name="Box2")
2123+
assert self.aedtapp.modeler.uncover_faces([c2.faces, b2.faces])
2124+
c3 = self.aedtapp.modeler.create_circle(orientation=AXIS.X, origin=[0, 10, 20], radius="3", name="Circle3")
2125+
b3 = self.aedtapp.modeler.create_box(origin=[-13.9, 0, 0], sizes=[27.8, -40, 25.4], name="Box3")
2126+
assert self.aedtapp.modeler.uncover_faces([c3.faces[0], b3.faces])
2127+
assert len(b3.faces) == 0

0 commit comments

Comments
 (0)