Implement sorting of spacial containers by elevation and name

This commit is contained in:
Manu Varkey
2024-09-06 17:29:25 +05:30
committed by Dion Moult
parent 2626165629
commit 1dfa3f8d79
+4
View File
@@ -452,6 +452,10 @@ class Spatial(bonsai.core.tool.Spatial):
new.is_expanded = element.id() not in cls.contracted_containers
new.level_index = level_index
children = ifcopenshell.util.element.get_parts(element)
if children:
children_elevations = [ifcopenshell.util.placement.get_storey_elevation(el) for el in children]
children_names = [[int(x) if x.isdigit() else x for x in (el.Name or "").split()] for el in children]
children = sorted(children, key=dict(zip(children, tuple(zip(children_elevations, children_names)))).get)
new.has_children = bool(children)
new.ifc_definition_id = element.id()
if new.is_expanded: