Add dumb wall feature

This commit is contained in:
Dion Moult
2020-08-11 17:24:30 +10:00
parent e858930755
commit e2fd9add83
2 changed files with 47 additions and 0 deletions
@@ -11,6 +11,8 @@ if bpy is not None:
from .module.covetool import ui as covetool_ui
from .module.covetool import operator as covetool_operator
from .module.model import wall as model_wall
classes = (
operator.AssignClass,
operator.UnassignClass,
@@ -266,6 +268,7 @@ if bpy is not None:
covetool_operator.Login,
covetool_operator.RunSimpleAnalysis,
covetool_operator.RunAnalysis,
model_wall.BIM_OT_add_object,
)
def menu_func_export(self, context):
@@ -301,6 +304,7 @@ if bpy is not None:
bpy.types.TextCurve.BIMTextProperties = bpy.props.PointerProperty(type=prop.BIMTextProperties)
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)
def unregister():
for cls in reversed(classes):
@@ -320,3 +324,4 @@ if bpy is not None:
del(bpy.types.Camera.BIMCameraProperties)
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)
@@ -0,0 +1,42 @@
import bpy
from bpy.types import Operator
from bpy.props import FloatVectorProperty, FloatProperty
from bpy_extras.object_utils import AddObjectHelper, object_data_add
from mathutils import Vector
def add_object(self, context):
verts = [
Vector((0, 0, 0)),
Vector((0, 0, self.height)),
Vector((self.length, 0, self.height)),
Vector((self.length, 0, 0)),
]
edges = []
faces = [[0, 1, 2, 3]]
mesh = bpy.data.meshes.new(name="New Dumb Wall")
mesh.from_pydata(verts, edges, faces)
obj = object_data_add(context, mesh, operator=self)
modifier = obj.modifiers.new('Wall Width', 'SOLIDIFY')
modifier.use_even_offset = True
modifier.thickness = self.width
class BIM_OT_add_object(Operator, AddObjectHelper):
bl_idname = "mesh.add_object"
bl_label = "Dumb Wall"
bl_options = {'REGISTER', 'UNDO'}
height: FloatProperty(name='Height', default=3)
length: FloatProperty(name='Length', default=1)
width: FloatProperty(name='Width', default=.2)
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')