IFC Stair - cosmetic adjustments

This commit is contained in:
Andrej730
2022-11-11 16:22:55 +06:00
committed by Dion Moult
parent f87b4a8072
commit 14e954545e
3 changed files with 28 additions and 15 deletions
@@ -256,18 +256,25 @@ class BIMArrayProperties(PropertyGroup):
class BIMStairProperties(PropertyGroup): class BIMStairProperties(PropertyGroup):
stair_types = (
("CONCRETE", "Concrete", ""),
("WOOD/STEEL", "Wood / Steel", ""),
)
is_editing: bpy.props.IntProperty(default=-1) is_editing: bpy.props.IntProperty(default=-1)
width: bpy.props.FloatProperty(name="Width", default=1.2, soft_min=0.01) width: bpy.props.FloatProperty(name="Width", default=1.2, soft_min=0.01)
height: bpy.props.FloatProperty(name="Height", default=1.0, soft_min=0.01) height: bpy.props.FloatProperty(name="Height", default=1.0, soft_min=0.01)
number_of_treads: bpy.props.IntProperty(name="Number of Treads (Goings)", default=6, soft_min=1) number_of_treads: bpy.props.IntProperty(name="Number of treads", default=6, soft_min=1)
tread_depth: bpy.props.FloatProperty(name="Tread Depth", default=0.25, soft_min=0.01) tread_depth: bpy.props.FloatProperty(name="Tread Depth", default=0.25, soft_min=0.01)
tread_run: bpy.props.FloatProperty(name="Tread Run", default=0.3, soft_min=0.01) tread_run: bpy.props.FloatProperty(name="Tread Run", default=0.3, soft_min=0.01)
base_slab_depth: bpy.props.FloatProperty(name="Base slab depth", default=0.25, soft_min=0) base_slab_depth: bpy.props.FloatProperty(name="Base slab depth", default=0.25, soft_min=0)
top_slab_depth: bpy.props.FloatProperty(name="Top slab depth", default=0.25, soft_min=0) top_slab_depth: bpy.props.FloatProperty(name="Top slab depth", default=0.25, soft_min=0)
has_top_nib: bpy.props.BoolProperty(name="Has top nib", default=True) 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): def get_props_kwargs(self):
kwargs = { kwargs = {
"stair_type": self.stair_type,
"width": self.width, "width": self.width,
"height": self.height, "height": self.height,
"number_of_treads": self.number_of_treads, "number_of_treads": self.number_of_treads,
@@ -92,7 +92,7 @@ def generate_stair_2d_profile(
has_top_nib, has_top_nib,
top_slab_depth, top_slab_depth,
base_slab_depth, base_slab_depth,
stair_type="CONCRETE", stair_type,
): ):
vertices = [] vertices = []
edges = [] edges = []
@@ -162,7 +162,6 @@ def update_stair_modifier(context):
props = obj.BIMStairProperties props = obj.BIMStairProperties
props_kwargs = props.get_props_kwargs() props_kwargs = props.get_props_kwargs()
props_kwargs["stair_type"] = "CONCRETE"
vertices, edges, faces = generate_stair_2d_profile(**props_kwargs) vertices, edges, faces = generate_stair_2d_profile(**props_kwargs)
obj = context.object obj = context.object
@@ -268,6 +267,7 @@ class AddStair(bpy.types.Operator, tool.Ifc.Operator):
element.NumberOfTreads = props.number_of_treads element.NumberOfTreads = props.number_of_treads
element.RiserHeight = props.height / element.NumberOfRisers element.RiserHeight = props.height / element.NumberOfRisers
element.TreadLength = props.tread_depth element.TreadLength = props.tread_depth
element.PredefinedType = "STRAIGHT"
return {"FINISHED"} return {"FINISHED"}
@@ -320,6 +320,7 @@ class FinishEditingStair(bpy.types.Operator, tool.Ifc.Operator):
element.NumberOfTreads = props.number_of_treads element.NumberOfTreads = props.number_of_treads
element.RiserHeight = props.height / element.NumberOfRisers element.RiserHeight = props.height / element.NumberOfRisers
element.TreadLength = props.tread_depth element.TreadLength = props.tread_depth
element.PredefinedType = "STRAIGHT"
return {"FINISHED"} return {"FINISHED"}
@@ -329,34 +329,39 @@ class BIM_PT_stair(bpy.types.Panel):
if StairData.data["parameters"]: if StairData.data["parameters"]:
row = self.layout.row(align=True) row = self.layout.row(align=True)
row.label(text="Stair", icon="IPO_CONSTANT") row.label(text="Stair parameters", icon="IPO_CONSTANT")
stair_data = StairData.data["parameters"]["data"] stair_data = StairData.data["parameters"]["data"]
box = self.layout.box()
if props.is_editing != -1: if props.is_editing != -1:
row = box.row(align=True) row = self.layout.row(align=True)
row.operator("bim.finish_editing_stair", icon="CHECKMARK", text="Finish editing") row.operator("bim.finish_editing_stair", icon="CHECKMARK", text="Finish editing")
row.operator("bim.cancel_editing_stair", icon="CANCEL", text="") row.operator("bim.cancel_editing_stair", icon="CANCEL", text="")
row = box.row(align=True) row = self.layout.row(align=True)
for prop_name in props.get_props_kwargs(): for prop_name in props.get_props_kwargs():
box.prop(props, prop_name) self.layout.prop(props, prop_name)
update_stair_modifier(context) update_stair_modifier(context)
else: else:
row = box.row(align=True)
row.label(text=f"Parameters:", icon="MOD_ARRAY")
row.operator("bim.enable_editing_stair", icon="GREASEPENCIL", text="") row.operator("bim.enable_editing_stair", icon="GREASEPENCIL", text="")
row.operator("bim.remove_stair", icon="X", text="") row.operator("bim.remove_stair", icon="X", text="")
row = box.row(align=True) row = self.layout.row(align=True)
for prop in props.get_props_kwargs(): for prop in props.get_props_kwargs():
prop_value = stair_data[prop] prop_value = stair_data[prop]
prop_value = round(prop_value, 5) if type(prop_value) is float else prop_value prop_value = round(prop_value, 5) if type(prop_value) is float else prop_value
box.label(text=f"{props.bl_rna.properties[prop].name}: {prop_value}") row = self.layout.row(align=True)
row.label(text=f"{props.bl_rna.properties[prop].name}")
row.label(text=str(prop_value))
# calculated properties # calculated properties
number_of_rises = props.number_of_treads + 1 number_of_rises = props.number_of_treads + 1
box.label(text=f"Number of risers: {number_of_rises}") row = self.layout.row(align=True)
box.label(text=f"Tread rise: {round(props.height / number_of_rises, 5)}") row.label(text="Number of risers")
box.label(text=f"Length: {round(props.tread_run * number_of_rises, 5)}") row.label(text=str(number_of_rises))
row = self.layout.row(align=True)
row.label(text="Tread rise")
row.label(text=str(round(props.height / number_of_rises, 5)))
row = self.layout.row(align=True)
row.label(text="Length")
row.label(text=str(round(props.tread_run * number_of_rises, 5)))
else: else:
row = self.layout.row() row = self.layout.row()
row.label(text="No Stair Found") row.label(text="No Stair Found")