OSArch Community

[How to] Create entity with ifcopenshell

  1. W

    I know there is a way to create an entity using:

    file = ifcopenshell.open('/path/to/your/file.ifc')

    obj = file.create_entity(name, **kwargs)

    Is there another way to create this object without an ifc file that already exists?

    That is, automatically create a class with IFC attributes that can become a super class of another python class.

    pseudo-code:

    > entity = ifcopenshell.create_entity(name)
     class MyClass(entity):
    
         ...

    I looked through the documentation and codes on GitHub, but I couldn't find anything that could guide me.

    I appreciate any help.

    Thanks

  2. A
  3. W

    @anders In this example, a temporary file is created.

    Write the template to a temporary file

    temp_handle, temp_filename = tempfile.mkstemp(suffix=".ifc")

    with open(temp_filename, "wb") as f:

    f.write(template)
  4. M
  5. W

    Ok, it works!

    Thank you very much.

Login or Register to reply.