mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
New dumb stair tool
This commit is contained in:
@@ -12,6 +12,7 @@ if bpy is not None:
|
||||
from .module.covetool import operator as covetool_operator
|
||||
|
||||
from .module.model import wall as model_wall
|
||||
from .module.model import stair as model_stair
|
||||
|
||||
classes = (
|
||||
operator.AssignClass,
|
||||
@@ -269,6 +270,7 @@ if bpy is not None:
|
||||
covetool_operator.RunSimpleAnalysis,
|
||||
covetool_operator.RunAnalysis,
|
||||
model_wall.BIM_OT_add_object,
|
||||
model_stair.BIM_OT_add_object,
|
||||
)
|
||||
|
||||
def menu_func_export(self, context):
|
||||
@@ -305,6 +307,7 @@ if bpy is not None:
|
||||
bpy.types.Scene.CoveToolProperties = bpy.props.PointerProperty(type=covetool_prop.CoveToolProperties)
|
||||
bpy.types.SCENE_PT_unit.append(ui.ifc_units)
|
||||
bpy.types.VIEW3D_MT_mesh_add.append(model_wall.add_object_button)
|
||||
bpy.types.VIEW3D_MT_mesh_add.append(model_stair.add_object_button)
|
||||
|
||||
def unregister():
|
||||
for cls in reversed(classes):
|
||||
@@ -325,3 +328,4 @@ if bpy is not None:
|
||||
del(bpy.types.Camera.BIMTextProperties)
|
||||
bpy.types.SCENE_PT_unit.remove(ui.ifc_units)
|
||||
bpy.types.VIEW3D_MT_mesh_add.remove(model_wall.add_object_button)
|
||||
bpy.types.VIEW3D_MT_mesh_add.remove(model_stair.add_object_button)
|
||||
|
||||
@@ -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