StairData refactor, solves #3416

This commit is contained in:
Andrej730
2023-07-14 16:16:52 +05:00
parent 38dd5a218c
commit 0fe3e56c63
3 changed files with 25 additions and 10 deletions
@@ -290,12 +290,27 @@ class StairData:
@classmethod
def load(cls):
cls.is_loaded = True
cls.data = {"pset_data": cls.pset_data()}
cls.data = {}
cls.data["pset_data"] = cls.pset_data()
if not cls.data["pset_data"]:
return
cls.data["general_params"] = cls.general_params()
@classmethod
def pset_data(cls):
return tool.Model.get_modeling_bbim_pset_data(bpy.context.active_object, "BBIM_Stair")
@classmethod
def general_params(cls):
props = bpy.context.active_object.BIMStairProperties
data = cls.data["pset_data"]["data_dict"]
general_params = {}
general_props = props.get_props_kwargs(stair_type=data["stair_type"])
for prop_name in general_props:
prop_readable_name, prop_value = get_prop_from_data(props, data, prop_name)
general_params[prop_readable_name] = prop_value
return general_params
class SverchokData:
data = {}
@@ -201,16 +201,18 @@ class BIMStairProperties(PropertyGroup):
has_top_nib: bpy.props.BoolProperty(name="Has top nib", default=True)
stair_type: bpy.props.EnumProperty(name="Stair type", items=stair_types, default="CONCRETE")
def get_props_kwargs(self, convert_to_project_units=False):
def get_props_kwargs(self, convert_to_project_units=False, stair_type=None):
if not stair_type:
stair_type = self.stair_type
stair_kwargs = {
"stair_type": self.stair_type,
"stair_type": stair_type,
"width": self.width,
"height": self.height,
"number_of_treads": self.number_of_treads,
"tread_run": self.tread_run,
}
if self.stair_type == "CONCRETE":
if stair_type == "CONCRETE":
concrete_props = {
"base_slab_depth": self.base_slab_depth,
"top_slab_depth": self.top_slab_depth,
@@ -219,13 +221,13 @@ class BIMStairProperties(PropertyGroup):
}
stair_kwargs.update(concrete_props)
elif self.stair_type == "WOOD/STEEL":
elif stair_type == "WOOD/STEEL":
wood_steel_props = {
"tread_depth": self.tread_depth,
}
stair_kwargs.update(wood_steel_props)
elif self.stair_type == "GENERIC":
elif stair_type == "GENERIC":
pass
if not convert_to_project_units:
@@ -269,11 +269,9 @@ class BIM_PT_stair(bpy.types.Panel):
row.operator("bim.enable_editing_stair", icon="GREASEPENCIL", text="")
row.operator("bim.remove_stair", icon="X", text="")
row = self.layout.row(align=True)
for prop in props.get_props_kwargs():
prop_value = stair_data[prop]
prop_value = round(prop_value, 5) if type(prop_value) is float else prop_value
for prop_name, prop_value in StairData.data["general_params"].items():
row = self.layout.row(align=True)
row.label(text=f"{props.bl_rna.properties[prop].name}")
row.label(text=prop_name)
row.label(text=str(prop_value))
# calculated properties