Tool to add storey to specific building

This commit is contained in:
Gorgious
2022-01-27 14:46:13 +01:00
parent 52739418d8
commit a1fb277188
2 changed files with 21 additions and 0 deletions
@@ -83,3 +83,6 @@ def select_similar_container(ifc, spatial, obj=None):
obj = ifc.get_object(subelement)
if obj:
spatial.select_object(obj)
def add_storey_to_building(spatial, obj):
spatial.add_building_storey(building=obj)
+18
View File
@@ -117,3 +117,21 @@ class Spatial(blenderbim.core.tool.Spatial):
@classmethod
def set_relative_object_matrix(cls, target_obj, relative_to_obj, matrix):
target_obj.matrix_world = relative_to_obj.matrix_world @ matrix
@classmethod
def get_name(cls, ifc_class, name):
if not bpy.data.objects.get(f"{ifc_class}/{name}"):
return name
i = 2
while bpy.data.objects.get(f"{ifc_class}/{name} {i}"):
i += 1
return f"{name} {i}"
@classmethod
def add_building_storey(cls, building):
building_storey = bpy.data.objects.new(cls.get_name("IfcBuildingStorey", "My Storey"), None)
bpy.ops.bim.assign_class(obj=building_storey.name, ifc_class="IfcBuildingStorey")
blenderbim.core.aggregate.assign_object(
tool.Ifc, tool.Aggregate, tool.Collector, relating_obj=building, related_obj=building_storey
)
cls.set_active_object(building)