mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
Add dumb opening feature
This commit is contained in:
@@ -17,6 +17,7 @@ if bpy is not None:
|
||||
from .module.model import door as model_door
|
||||
from .module.model import window as model_window
|
||||
from .module.model import slab as model_slab
|
||||
from .module.model import opening as model_opening
|
||||
|
||||
classes = (
|
||||
operator.AssignClass,
|
||||
@@ -297,6 +298,7 @@ if bpy is not None:
|
||||
model_door.BIM_OT_add_object,
|
||||
model_window.BIM_OT_add_object,
|
||||
model_slab.BIM_OT_add_object,
|
||||
model_opening.BIM_OT_add_object,
|
||||
)
|
||||
|
||||
def menu_func_export(self, context):
|
||||
@@ -338,6 +340,7 @@ if bpy is not None:
|
||||
bpy.types.VIEW3D_MT_mesh_add.append(model_door.add_object_button)
|
||||
bpy.types.VIEW3D_MT_mesh_add.append(model_window.add_object_button)
|
||||
bpy.types.VIEW3D_MT_mesh_add.append(model_slab.add_object_button)
|
||||
bpy.types.VIEW3D_MT_mesh_add.append(model_opening.add_object_button)
|
||||
|
||||
def unregister():
|
||||
for cls in reversed(classes):
|
||||
@@ -363,3 +366,4 @@ if bpy is not None:
|
||||
bpy.types.VIEW3D_MT_mesh_add.remove(model_door.add_object_button)
|
||||
bpy.types.VIEW3D_MT_mesh_add.remove(model_window.add_object_button)
|
||||
bpy.types.VIEW3D_MT_mesh_add.remove(model_slab.add_object_button)
|
||||
bpy.types.VIEW3D_MT_mesh_add.remove(model_opening.add_object_button)
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
import bpy
|
||||
import bmesh
|
||||
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):
|
||||
bm = bmesh.new()
|
||||
bmesh.ops.create_cube(bm, size=self.size)
|
||||
bm.verts.ensure_lookup_table()
|
||||
bm.edges.ensure_lookup_table()
|
||||
bm.faces.ensure_lookup_table()
|
||||
mesh = bpy.data.meshes.new(name="Dumb Opening")
|
||||
bm.to_mesh(mesh)
|
||||
bm.free()
|
||||
obj = object_data_add(context, mesh, operator=self)
|
||||
obj.name = 'IfcOpening/Dumb Opening'
|
||||
obj.display_type = 'WIRE'
|
||||
attribute = obj.BIMObjectProperties.attributes.add()
|
||||
attribute.name = 'PredefinedType'
|
||||
attribute.string_value = 'OPENING'
|
||||
|
||||
|
||||
class BIM_OT_add_object(Operator, AddObjectHelper):
|
||||
bl_idname = "mesh.add_opening"
|
||||
bl_label = "Dumb Opening"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
|
||||
size: FloatProperty(name='Size', 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')
|
||||
Reference in New Issue
Block a user