From 166ddb479917d14abc8ab6f4de18ac441044c35a Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Thu, 13 Nov 2025 18:47:30 +0500 Subject: [PATCH] Fix parametric stair editing after 3617d11 #7355 --- src/bonsai/bonsai/bim/module/model/prop.py | 9 +++++++-- src/bonsai/bonsai/tool/model.py | 5 +++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/bonsai/bonsai/bim/module/model/prop.py b/src/bonsai/bonsai/bim/module/model/prop.py index bea28085d5..fd5397fe36 100644 --- a/src/bonsai/bonsai/bim/module/model/prop.py +++ b/src/bonsai/bonsai/bim/module/model/prop.py @@ -628,14 +628,19 @@ class BIMStairProperties(PropertyGroup): def set_props_kwargs_from_ifc_data(self, kwargs): kwargs = tool.Model.convert_data_to_si_units(kwargs, self.non_si_units_props) + tread_run = kwargs.get("tread_run", 0.3) # Determine lock state based on whether custom treads match tread_run # If custom_tread_lock wasn't saved (old files), infer it from the data if "custom_tread_lock" not in kwargs: custom_treads = kwargs.get("custom_first_last_tread_run", (0.0, 0.0)) - tread_run = kwargs.get("tread_run", 0.3) # Lock is off if either custom tread differs from tread_run and is not 0 - kwargs["custom_tread_lock"] = not any(ct != 0.0 and ct != tread_run for ct in custom_treads) + kwargs["custom_tread_lock"] = all(ct not in (0.0, tread_run) for ct in custom_treads) + + if "custom_first_last_tread_run" in kwargs: + custom_treads = kwargs["custom_first_last_tread_run"] + custom_treads = [tread_run if v is None else v for v in custom_treads] + kwargs["custom_first_last_tread_run"] = custom_treads for prop_name in kwargs: setattr(self, prop_name, kwargs[prop_name]) diff --git a/src/bonsai/bonsai/tool/model.py b/src/bonsai/bonsai/tool/model.py index e4685c54f4..0627b400ed 100644 --- a/src/bonsai/bonsai/tool/model.py +++ b/src/bonsai/bonsai/tool/model.py @@ -142,9 +142,10 @@ class Model(bonsai.core.tool.Model): for prop_name in data: if prop_name in non_si_props: continue - prop_value = data[prop_name] + # `None` is used by `custom_first_last_tread_run`. + prop_value: Iterable[float | None] | float = data[prop_name] if isinstance(prop_value, collections.abc.Iterable): - data[prop_name] = [v * si_conversion for v in prop_value] + data[prop_name] = [v if v is None else v * si_conversion for v in prop_value] else: data[prop_name] = prop_value * si_conversion return data