Hi, I'm trying to select a Polyhedron and copy some of its faces, but I can't find the right method to do it. Could someone point me in the right direction?
Das Wissen aller Anwender nutzen
Im Allplan Connect Forum tauschen sich Anwender aus, geben wertvolle Tipps oder beraten sich bei ganz konkreten Aufgabenstellungen − auch international.
Und damit wirklich keine Frage unbeantwortet bleibt, unterstützen die Mitarbeiter des Technischen Supports ebenfalls aktiv das Forum.
Es erwarten Sie:
- Foren-Vielfalt aus CAD Architektur, CAD Ingenieurbau uvm.
- Tipps von User für User
- international: Deutsch, Englisch, Italienisch, Französisch und Tschechisch
Melden Sie sich jetzt an und diskutieren Sie mit!
- Forum
- CAD Parametric Modelling
- PythonParts
[Frage] Copy a Face of Polyhedron
Hilfreichste Antwort anzeigen Hilfreichste Antwort verbergen
Hi,
there is no dedicated function for your use-case, but try this
def get_face_polygons(polyhedron: AllplanGeo.Polyhedron3D) -> list[AllplanGeo.Polygon3D]: """Extracts the face polygons from a polyhedron. Args: polyhedron (AllplanGeo.Polyhedron3D): The polyhedron from which to extract the faces. Returns: list[AllplanGeo.Polygon3D]: A list of polygons representing the faces of the polyhedron. """ face_polygons: list[AllplanGeo.Polygon3D] = [] for idx in range(polyhedron.GetFacesCount()): face = polyhedron.GetFace(idx) face_polygon = AllplanGeo.Polygon3D() for edge in face.GetEdges(): _, start, end = polyhedron.GetEdgeVertices(edge) face_polygon += start face_polygon += end face_polygons.append(face_polygon) return face_polygons
It worked on my side.
Cheers,
Bart
Hi.
Can you tell more about the workflow? So the user selects a polyhedron, not a face. What criteria do you want to use to get the faces? And what should be the output? A Polygon3D?
Cheers,
Bart
I would like to select a solid (Polyhedron 3D) and "extract" all the faces (and then filter them based on riles that I can define). the problem is that I found methods that give me the vertices or the edges of the face, but not the actual face. I didn't find something like GetFace3D....
Hi,
there is no dedicated function for your use-case, but try this
def get_face_polygons(polyhedron: AllplanGeo.Polyhedron3D) -> list[AllplanGeo.Polygon3D]: """Extracts the face polygons from a polyhedron. Args: polyhedron (AllplanGeo.Polyhedron3D): The polyhedron from which to extract the faces. Returns: list[AllplanGeo.Polygon3D]: A list of polygons representing the faces of the polyhedron. """ face_polygons: list[AllplanGeo.Polygon3D] = [] for idx in range(polyhedron.GetFacesCount()): face = polyhedron.GetFace(idx) face_polygon = AllplanGeo.Polygon3D() for edge in face.GetEdges(): _, start, end = polyhedron.GetEdgeVertices(edge) face_polygon += start face_polygon += end face_polygons.append(face_polygon) return face_polygons
It worked on my side.
Cheers,
Bart