mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 14:41:25 +00:00
New dumb stair tool
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
import bpy
|
||||
from bpy.types import Operator
|
||||
from bpy.props import FloatVectorProperty, FloatProperty, IntProperty
|
||||
from bpy_extras.object_utils import AddObjectHelper, object_data_add
|
||||
from mathutils import Vector
|
||||
|
||||
def add_object(self, context):
|
||||
if self.number_of_treads <= 0:
|
||||
self.number_of_treads = 1
|
||||
verts = [
|
||||
Vector((0, 0, 0)),
|
||||
Vector((0, self.tread_length, 0)),
|
||||
Vector((self.width, self.tread_length, 0)),
|
||||
Vector((self.width, 0, 0)),
|
||||
]
|
||||
edges = []
|
||||
faces = [[0, 1, 2, 3]]
|
||||
|
||||
mesh = bpy.data.meshes.new(name="New Dumb Stair")
|
||||
mesh.from_pydata(verts, edges, faces)
|
||||
obj = object_data_add(context, mesh, operator=self)
|
||||
modifier = obj.modifiers.new('Stair Width', 'SOLIDIFY')
|
||||
modifier.use_even_offset = True
|
||||
modifier.offset = 1
|
||||
modifier.thickness = self.tread_depth
|
||||
modifier = obj.modifiers.new('Stair Treads', 'ARRAY')
|
||||
modifier.relative_offset_displace[0] = 0
|
||||
modifier.relative_offset_displace[1] = 1
|
||||
modifier.use_constant_offset = True
|
||||
modifier.constant_offset_displace[2] = self.height / self.number_of_treads
|
||||
modifier.count = self.number_of_treads
|
||||
self.riser_height = self.height / self.number_of_treads
|
||||
self.length = self.number_of_treads * self.tread_length
|
||||
|
||||
|
||||
class BIM_OT_add_object(Operator, AddObjectHelper):
|
||||
bl_idname = "mesh.add_stair"
|
||||
bl_label = "Dumb Stair"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
||||
width: FloatProperty(name='Width', default=1.1)
|
||||
height: FloatProperty(name='Height', default=1)
|
||||
tread_depth: FloatProperty(name='Tread Depth', default=.2)
|
||||
number_of_treads: IntProperty(name='Number of Treads (Goings)', default=6)
|
||||
tread_length: FloatProperty(name='Tread Length (Going)', default=.25)
|
||||
riser_height: FloatProperty(name='*Calculated* Riser Height')
|
||||
length: FloatProperty(name='*Calculated* Length')
|
||||
|
||||
def execute(self, context):
|
||||
add_object(self, context)
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
def add_object_button(self, context):
|
||||
self.layout.operator(
|
||||
BIM_OT_add_object.bl_idname,
|
||||
icon='PLUGIN')
|
||||
@@ -23,7 +23,7 @@ def add_object(self, context):
|
||||
|
||||
|
||||
class BIM_OT_add_object(Operator, AddObjectHelper):
|
||||
bl_idname = "mesh.add_object"
|
||||
bl_idname = "mesh.add_wall"
|
||||
bl_label = "Dumb Wall"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user