diff --git a/src/blenderbim/blenderbim/bim/module/model/data.py b/src/blenderbim/blenderbim/bim/module/model/data.py index c5b44b9c8b..2f3b69a85c 100644 --- a/src/blenderbim/blenderbim/bim/module/model/data.py +++ b/src/blenderbim/blenderbim/bim/module/model/data.py @@ -333,25 +333,7 @@ class StairData: @classmethod def calculated_params(cls): - props = bpy.context.active_object.BIMStairProperties - - if props.is_editing: - si_conversion = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get()) - number_of_treads = props.number_of_treads - height = props.height / si_conversion - tread_run = props.tread_run / si_conversion - else: - data = cls.data["pset_data"]["data_dict"] - number_of_treads = data["number_of_treads"] - height = data["height"] - tread_run = data["tread_run"] - - calculated_params = {} - number_of_rises = number_of_treads + 1 - calculated_params["Number of risers"] = number_of_rises - calculated_params["Tread rise"] = round(height / number_of_rises, 5) - calculated_params["Length"] = round(tread_run * number_of_rises, 5) - return calculated_params + return tool.Model.get_active_stair_calculated_params(cls.data["pset_data"]["data_dict"]) class SverchokData: diff --git a/src/blenderbim/blenderbim/bim/module/model/ui.py b/src/blenderbim/blenderbim/bim/module/model/ui.py index 4e2047996c..b6d07b9fff 100644 --- a/src/blenderbim/blenderbim/bim/module/model/ui.py +++ b/src/blenderbim/blenderbim/bim/module/model/ui.py @@ -259,8 +259,8 @@ class BIM_PT_stair(bpy.types.Panel): row = self.layout.row(align=True) row.label(text="Stair parameters", icon="IPO_CONSTANT") - stair_data = StairData.data["pset_data"]["data_dict"] if props.is_editing: + calculated_params = tool.Model.get_active_stair_calculated_params() row = self.layout.row(align=True) row.operator("bim.finish_editing_stair", icon="CHECKMARK", text="Finish Editing") row.operator("bim.cancel_editing_stair", icon="CANCEL", text="") @@ -269,6 +269,7 @@ class BIM_PT_stair(bpy.types.Panel): self.layout.prop(props, prop_name) regenerate_stair_mesh(context) else: + calculated_params = StairData.data["calculated_params"] row.operator("bim.enable_editing_stair", icon="GREASEPENCIL", text="") row.operator("bim.remove_stair", icon="X", text="") row = self.layout.row(align=True) @@ -278,7 +279,7 @@ class BIM_PT_stair(bpy.types.Panel): row.label(text=str(prop_value)) # calculated properties - for prop_name, prop_value in StairData.data["calculated_params"].items(): + for prop_name, prop_value in calculated_params.items(): row = self.layout.row(align=True) row.label(text=prop_name) row.label(text=str(prop_value)) diff --git a/src/blenderbim/blenderbim/tool/model.py b/src/blenderbim/blenderbim/tool/model.py index 54d24ba15e..11f0573d49 100644 --- a/src/blenderbim/blenderbim/tool/model.py +++ b/src/blenderbim/blenderbim/tool/model.py @@ -908,6 +908,27 @@ class Model(blenderbim.core.tool.Model): def is_parametric_door_active(cls): return (DoorData.is_loaded or not DoorData.load()) and DoorData.data["pset_data"] + @classmethod + def get_active_stair_calculated_params(cls, pset_data=None): + props = bpy.context.active_object.BIMStairProperties + + if props.is_editing: + si_conversion = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get()) + number_of_treads = props.number_of_treads + height = props.height / si_conversion + tread_run = props.tread_run / si_conversion + else: + number_of_treads = pset_data["number_of_treads"] + height = pset_data["height"] + tread_run = pset_data["tread_run"] + + calculated_params = {} + number_of_rises = number_of_treads + 1 + calculated_params["Number of risers"] = number_of_rises + calculated_params["Tread rise"] = round(height / number_of_rises, 5) + calculated_params["Length"] = round(tread_run * number_of_rises, 5) + return calculated_params + @classmethod def generate_stair_2d_profile( cls,