Resize object to storey now works for a variable number of storeys

This commit is contained in:
Dion Moult
2021-10-28 19:06:27 +11:00
parent 4bb549f3e9
commit d013d6ed09
10 changed files with 50 additions and 31 deletions
+4 -6
View File
@@ -40,7 +40,7 @@ class Misc(blenderbim.core.tool.Misc):
return elevation * unit_scale
@classmethod
def get_storey_height_in_si(cls, storey):
def get_storey_height_in_si(cls, storey, total_storeys):
building = ifcopenshell.util.element.get_aggregate(storey)
related_objects = []
for rel in building.IsDecomposedBy:
@@ -50,14 +50,12 @@ class Misc(blenderbim.core.tool.Misc):
related_objects.append((element, ifcopenshell.util.placement.get_storey_elevation(element)))
related_objects = sorted(related_objects, key=lambda e: e[1])
storey_elevation = None
next_storey_elevation = None
for related_object in related_objects:
for i, related_object in enumerate(related_objects):
if related_object[0] == storey:
storey_elevation = related_object[1]
elif storey_elevation is not None:
next_storey_elevation = related_object[1]
break
if next_storey_elevation:
if i + total_storeys < len(related_objects):
next_storey_elevation = related_objects[i + total_storeys][1]
unit_scale = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
return (next_storey_elevation - storey_elevation) * unit_scale