IFC Stair - added "Wood / Steel" stair type

Added new stair type "Wood / Steel" to IFC Stair modifier. It's less sophisticated than "Concrete" stair type - it acts more like a "Dumb stair" operator we have.
This commit is contained in:
Andrej730
2022-11-11 17:32:57 +06:00
parent 31b633b8b6
commit 9dfd7e03f7
2 changed files with 92 additions and 62 deletions
@@ -273,7 +273,8 @@ class BIMStairProperties(PropertyGroup):
stair_type: bpy.props.EnumProperty(name="Stair type", items=stair_types, default="CONCRETE") stair_type: bpy.props.EnumProperty(name="Stair type", items=stair_types, default="CONCRETE")
def get_props_kwargs(self): def get_props_kwargs(self):
kwargs = { if self.stair_type == "CONCRETE":
return {
"stair_type": self.stair_type, "stair_type": self.stair_type,
"width": self.width, "width": self.width,
"height": self.height, "height": self.height,
@@ -284,4 +285,12 @@ class BIMStairProperties(PropertyGroup):
"top_slab_depth": self.top_slab_depth, "top_slab_depth": self.top_slab_depth,
"has_top_nib": self.has_top_nib, "has_top_nib": self.has_top_nib,
} }
return kwargs elif self.stair_type == "WOOD/STEEL":
return {
"stair_type": self.stair_type,
"width": self.width,
"height": self.height,
"number_of_treads": self.number_of_treads,
"tread_depth": self.tread_depth,
"tread_run": self.tread_run,
}
@@ -89,18 +89,39 @@ def generate_stair_2d_profile(
width, width,
tread_run, tread_run,
tread_depth, tread_depth,
has_top_nib,
top_slab_depth,
base_slab_depth,
stair_type, stair_type,
# CONCRETE STAIR ARGUMENTS
has_top_nib=None,
top_slab_depth=None,
base_slab_depth=None,
): ):
vertices = [] vertices = []
edges = [] edges = []
faces = []
number_of_risers = number_of_treads + 1 number_of_risers = number_of_treads + 1
tread_rise = height / number_of_risers tread_rise = height / number_of_risers
length = tread_run * number_of_risers length = tread_run * number_of_risers
if stair_type == "WOOD/STEEL":
for i in range(number_of_risers):
v1 = Vector(((i + 1) * tread_run, 0, (i + 1) * tread_rise))
v0 = v1 - Vector((tread_run, 0, 0))
v2 = v1 - Vector((0, 0, tread_depth))
v3 = v0 - Vector((0, 0, tread_depth))
vertices.extend([v0, v1, v2, v3])
cur_vertex = i * 4
edges.extend([
(cur_vertex, cur_vertex+1),
(cur_vertex+1, cur_vertex+2),
(cur_vertex+2, cur_vertex+3),
(cur_vertex+3, cur_vertex),
])
faces.append(list(range(4 * i, 4 * i + 1)))
return (vertices, edges, faces)
elif stair_type == "CONCRETE":
for i in range(number_of_risers): for i in range(number_of_risers):
vertices.extend([ vertices.extend([
Vector((tread_run*i, 0, tread_rise*i)), Vector((tread_run*i, 0, tread_rise*i)),
@@ -177,7 +198,7 @@ def update_stair_modifier(context):
bmesh.ops.contextual_create(bm, geom=new_edges) bmesh.ops.contextual_create(bm, geom=new_edges)
bm.faces.ensure_lookup_table() bm.faces.ensure_lookup_table()
faces = [bm.faces[0]] faces = bm.faces
extruded = bmesh.ops.extrude_face_region(bm, geom=faces) extruded = bmesh.ops.extrude_face_region(bm, geom=faces)
extrusion_vector = Vector((0, 1, 0)) * props.width extrusion_vector = Vector((0, 1, 0)) * props.width
translate_verts = [v for v in extruded["geom"] if isinstance(v, BMVert)] translate_verts = [v for v in extruded["geom"] if isinstance(v, BMVert)]