Get geometry from a IFC 3D entity using Ifcopenshell and OpenCascade

2.2k views Asked by At

I have multiple standard formed bricks in an IFC file of the type IfcBuildingElementProxy. While I already managed to extract their positions from the IFC file, I now struggle to get the geometry (lenght, height, widht) from the file. I know that there are 2 ways to get the geometry:

  1. parse trough the representation attributes of the bricks and try to write a code, that calculates the geometry. This method is really exhausting, as IFC files tend to work with a lot of references. I won't go this path.

  2. get the geometry using a engine like ifcopenshell and opencascade. I know how to cast the bricks into a TopoDS object, but struggle to find the right methods to get the geometry.

import ifcopenshell

bricklist = ifc_file.by_type('IfcBuildingElementProxy') 

for brick in bricklist:
        shape = ifcopenshell.geom.create_shape(settings, brick).geometry
        shape.methodtogetXYZgemeometrics???
1

There are 1 answers

1
sinsro On

Use

settings = geom.settings()
settings.set(settings.USE_WORLD_COORDS, True) #Translates and rotates the points to their world coordinates

...

shape = geom.create_shape(settings , brick )
points=shape.geometry.verts     #The xyz points
triangles=shape.geometry.faces  #Indexes to the points, 3 indexes form one triangle

Note that you can also use the element's 4x3 rotation/translation matrix and do the points translation yourself if you do not use the USE_WORLD_COORDS setting. This matrix is given by

shape.transformation.matrix.data