W
by walpa on 20 Mar 2021, edited 21 Mar 2021
#
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
A
by anders on 20 Mar 2021
#
I don't think there's a direct way to create an IFC from scratch, but you can of course create a template yourself, like in this example (2x3, but can easily be adapted to produce valid IFC4 files): http://academy.ifcopenshell.org/creating-a-simple-wall-with-property-set-and-quantity-information/
W
by walpa on 20 Mar 2021
#
@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)
M
by Moult on 21 Mar 2021
#
More reading: https://wiki.osarch.org/index.php?title=IfcOpenShell_code_examples
f = ifcopenshell.file()
f.create_entity(...)