@Max said:
Thank a lot, the script works perfectly and is really useful. One thing that I wonder if it would be possible to name the planes after the storeys?
Yes, just add
bpy.context.active_object.name = str(ifcproduct.Name)
at the end of the for loop, so the script now looks like this:
import bpy
import ifcopenshell
import blenderbim.bim.import_ifc
from blenderbim.bim.ifc import IfcStore
ifc_file = ifcopenshell.open(IfcStore.path)
products = ifc_file.by_type('IfcProduct')
for ifcproduct in products:
if ifcproduct:
if ifcproduct.is_a() == "IfcBuildingStorey":
x = (ifcproduct.ObjectPlacement.RelativePlacement.Location.Coordinates[0])
y = (ifcproduct.ObjectPlacement.RelativePlacement.Location.Coordinates[1])
z = (ifcproduct.ObjectPlacement.RelativePlacement.Location.Coordinates[2])
print (x, y, z, ifcproduct.Elevation)
print (ifcproduct.ObjectPlacement)
bpy.ops.mesh.primitive_plane_add(size=50, enter_editmode=False, align='WORLD', location=(x, y, (ifcproduct.Elevation)/1000), scale=(1, 1, 1))
bpy.context.active_object.name = str(ifcproduct.Name)
bpy.ops.bim.assign_class(ifc_class="IfcBuildingElementProxy", predefined_type="", userdefined_type="")
I also added the assignment of the IfcElement, I don't know yet how to assign the plane to each correct IfcBuidingStorey, the IfcOpenShell api is confusing me, I don't think it should be that hard. If the IfcProduct.Elevation isNone
in some IFC models, you could try to use the z
variable instead.
EDIT:
Just amazing how BlenderBIM is able to facilitate adding a plane in IFC in a relatively easy way. Imagine doing this in Revit, what a hassle that would be...The IFC model would still be loading....
Little examples like this really show the added value of BlenderBIM.