From be090a3a817df673af9fdea83bceed6927d0adeb Mon Sep 17 00:00:00 2001 From: Manu Varkey Date: Tue, 10 Sep 2024 09:44:27 +0530 Subject: [PATCH] Fixes #5353 (#5354) * Fixes #5353 * Change logic to use natsorted --- src/bonsai/bonsai/tool/spatial.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/bonsai/bonsai/tool/spatial.py b/src/bonsai/bonsai/tool/spatial.py index f7ff898296..e4147c61bc 100644 --- a/src/bonsai/bonsai/tool/spatial.py +++ b/src/bonsai/bonsai/tool/spatial.py @@ -42,6 +42,7 @@ from mathutils import Vector, Matrix from shapely import Polygon from typing import Generator, Optional, Union, Literal, List, Any, Iterable from collections import defaultdict +from natsort import natsorted class Spatial(bonsai.core.tool.Spatial): @@ -454,8 +455,8 @@ class Spatial(bonsai.core.tool.Spatial): 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) + children_names = [el.Name or "" for el in children] + children = natsorted(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: