mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
Fixed stair calculated params not updating during edit (after 8b23c615c)
.data doesn't update on props change, so need to take data from props explicitly when BIMStairProperties.is_editing
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user