icon

Forum de la communauté Allplan

[Question] Copy a Face of Polyhedron


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?

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