How to generate a 3D polygon in python using ifc vertices ?

Hi,

I'm currently working with python (3.8) and ifcopenshell and I'd like to use ifcopenshell's geometry vertices to create a 3D polygon at runtime. The polygons I'd like to create are pretty simple, it is only walls composed of less than 80 vertices.
I tried using pyny3d but it seems like it's not working properly, only drawing a face and not even properly in most cases. I can't use mpl_toolkits because it only works with planar 3D polygon.

My idea was maybe to use pyny3d's polyhedron and to try to draw the walls faces in separated polygon but I'm not sure. What are my possible solutions in order to do it easily ?

Comments

  • Geometry does depends on vertices AND polygons definition (either triangle / n-gons) ifc[open|closed]shell for breps, the most difficult part is the way holes are handled in polygons.
    Ifc does handle holes in polygons, where 3d packages usually don't, keeping 2 opposite edges between boundary and hole.

  • My advice is to use IfcOpenShell's geometry iterator to process the geometry that you want displayed. See sample code here: https://wiki.osarch.org/index.php?title=IfcOpenShell_code_examples#Geometry_processing

    Once you get the shape variable, it holds all the verts, edges, and faces, and automatically resolves any required tessellations including polygons with holes. Then, you can use that to translate to your output engine.

    baldash
  • Thanks for the answer but actually I don't know about which library I could use to display at runtime the shapes returned by ifcopenshell, any recommendations?

  • @baldash you can do it within an app like Blender or FreeCAD, or via a more barebones viewer such as the Qt 3D viewer: https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.6.0/src/ifcopenshell-python/ifcopenshell/geom/app.py - the former strategies give you a lot more batteries included, though.

  • Oh okay so this kind of complex geometry can only be processed by 3D softwares if I understand correctly ?

  • @baldash if you want to display geometry on a screen, most commonly you would rely on an existing geometry display library or application.

Sign In or Register to comment.