[IfcOpenShell-Python] from obj file to ifc file

Hi all, if you have an obj file, here for example a cube:
Link to obj file
How can you put this cube geometry from the obj file to an ifc entity like IfcWall?
I am aware that with
ifc = ifcopenshell.file()
as described here, we can create an ifc file and a ifc entity.

However how can I now give the geometry from the obj file to the ifcWall entity?


  • edited August 5

    Not 100% sure, as i'm a noobie, as well.
    But could the answer be gleaned from here and here?

  • You mean automated completely?
    Or manually?
    Because with Blender it's possible to import an .obj:

    Then you could use the BlenderBIM to make assign the geometry.

  • @Coen The possibility with Blender with BlenderBIM goes well, but I would like it to go automatically.
    Ideally i want to build a python script that automatically converts many obj file with metadata to ifc file. But I'm stuck on how to add the geomtery of an obj to an ifc entity with python.

    @theoryshaw Thanks for the link, but i am also a noobie here. So I do not know if this helps me further :(

    Here below procedure manual with Blender with BlenderBIM to create ifc file with geometry from obj file:
    1. import obj file

    2. create ifc project with BlenderBIM

    3. assign IFC entity to cube

    4. move IFC entity to right place in ifc tree view

    5. save ifc project

  • Hi @Martin156131
    This YouTube video by Johnny Matthews could be a method to achieve what you are after

  • I tried to assign the cube to an IFCSpace but that was not an option I could find.

  • @Max said:
    I tried to assign the cube to an IFCSpace but that was not an option I could find.

    Within the UI?

    Programmatically, I believe it should be something like:

    bpy.ops.bim.assign_class(obj='Cube', ifc_class='IfcSpace', predefined_type='EXTERNAL')
  • While searching for a solution to my problem, I came across this script named obj2ifc.py on IfcOpenShell's github page.

    With it you can create an ifc from an obj file with a one-liner on the CLI:
    python obj2ifc.py cubus.obj
    That's really cool.

    However i have two problems with it, that i couldn't solve myself:
    1. On line 77 the default is version="IFC2X3", when i changed it to version="IFC4", the script throws me a error and i don't know how to debug it.
    2. On line 36 the default is collect_faces=True

    collect_faces will collect triangle face data for every mesh. In case faces with more than three vertices are specified they will be triangulated

    Quote from here

    That's creating weird faces.

    If you open this test testface.obj in Blender you see this:

    However using this script creates this:

    But if I set collect_fase = "False", the script does not work at all.

    @Nigel Thanks for the video, it was quite impressive how easy it is to script in Blender with Python and save yourself time. If the way with the script obj2ifc does not work, I try it with Blender.

Sign In or Register to comment.