Files
IfcOpenShell/src/ifcblenderexport/blenderbim/bim/module/model/opening.py
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

36 lines
973 B
Python
Raw Normal View History

2020-08-21 20:38:57 +10:00
import bpy
import bmesh
from bpy.types import Operator
2020-11-13 15:50:37 +07:00
from bpy.props import FloatProperty
2020-08-21 20:38:57 +10:00
from bpy_extras.object_utils import AddObjectHelper, object_data_add
2020-11-01 20:08:48 +07:00
2020-08-21 20:38:57 +10:00
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 = "Opening"
2020-11-01 20:08:48 +07:00
obj.display_type = "WIRE"
2020-08-21 20:38:57 +10:00
class BIM_OT_add_object(Operator, AddObjectHelper):
bl_idname = "mesh.add_opening"
bl_label = "Dumb Opening"
2020-11-01 20:08:48 +07:00
bl_options = {"REGISTER", "UNDO"}
2020-08-21 20:38:57 +10:00
2020-11-01 20:08:48 +07:00
size: FloatProperty(name="Size", default=2)
2020-08-21 20:38:57 +10:00
def execute(self, context):
add_object(self, context)
2020-11-01 20:08:48 +07:00
return {"FINISHED"}
2020-08-21 20:38:57 +10:00
def add_object_button(self, context):
2020-11-01 20:08:48 +07:00
self.layout.operator(BIM_OT_add_object.bl_idname, icon="PLUGIN")