mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-10-03 13:28:19 +00:00
black ifcblenderexport
This commit is contained in:
@@ -6,42 +6,62 @@ 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):
|
||||
guid = ifcopenshell.guid.new()
|
||||
leaf_width = self.overall_width-0.045-0.045
|
||||
leaf_width = self.overall_width - 0.045 - 0.045
|
||||
verts = [
|
||||
# Left lining
|
||||
Vector((0, 0, 0)),
|
||||
Vector((0, self.depth, 0)),
|
||||
Vector((.04, self.depth, 0)),
|
||||
Vector((.04, self.depth-.04, 0)),
|
||||
Vector((.065, self.depth-.04, 0)),
|
||||
Vector((.065, 0, 0)),
|
||||
Vector((0.04, self.depth, 0)),
|
||||
Vector((0.04, self.depth - 0.04, 0)),
|
||||
Vector((0.065, self.depth - 0.04, 0)),
|
||||
Vector((0.065, 0, 0)),
|
||||
# Right lining
|
||||
Vector((self.overall_width, 0, 0)),
|
||||
Vector((self.overall_width, self.depth, 0)),
|
||||
Vector((self.overall_width-.04, self.depth, 0)),
|
||||
Vector((self.overall_width-.04, self.depth-.04, 0)),
|
||||
Vector((self.overall_width-.065, self.depth-.04, 0)),
|
||||
Vector((self.overall_width-.065, 0, 0)),
|
||||
Vector((self.overall_width - 0.04, self.depth, 0)),
|
||||
Vector((self.overall_width - 0.04, self.depth - 0.04, 0)),
|
||||
Vector((self.overall_width - 0.065, self.depth - 0.04, 0)),
|
||||
Vector((self.overall_width - 0.065, 0, 0)),
|
||||
# Door panel
|
||||
Vector((.045, self.depth, 0)),
|
||||
Vector((.045, self.depth+leaf_width, 0)),
|
||||
Vector((.080, self.depth+leaf_width, 0)),
|
||||
Vector((.080, self.depth, 0)),
|
||||
Vector((0.045, self.depth, 0)),
|
||||
Vector((0.045, self.depth + leaf_width, 0)),
|
||||
Vector((0.080, self.depth + leaf_width, 0)),
|
||||
Vector((0.080, self.depth, 0)),
|
||||
]
|
||||
edges = [
|
||||
[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], # Left lining
|
||||
[6, 7], [7, 8], [8, 9], [9, 10], [10, 11], # Right lining
|
||||
[12, 13], [13, 14], [14, 15], [15, 12], # Door panel
|
||||
[0, 1],
|
||||
[1, 2],
|
||||
[2, 3],
|
||||
[3, 4],
|
||||
[4, 5], # Left lining
|
||||
[6, 7],
|
||||
[7, 8],
|
||||
[8, 9],
|
||||
[9, 10],
|
||||
[10, 11], # Right lining
|
||||
[12, 13],
|
||||
[13, 14],
|
||||
[14, 15],
|
||||
[15, 12], # Door panel
|
||||
]
|
||||
# Door swing
|
||||
for i in range(0, 9):
|
||||
verts.append(Vector((0.045+(leaf_width*math.cos((math.pi/2)/8*i)), self.depth+(leaf_width*math.sin((math.pi/2)/8*i)), 0)))
|
||||
edges.append([16+i, 17+i])
|
||||
verts.append(
|
||||
Vector(
|
||||
(
|
||||
0.045 + (leaf_width * math.cos((math.pi / 2) / 8 * i)),
|
||||
self.depth + (leaf_width * math.sin((math.pi / 2) / 8 * i)),
|
||||
0,
|
||||
)
|
||||
)
|
||||
)
|
||||
edges.append([16 + i, 17 + i])
|
||||
edges.pop()
|
||||
faces = []
|
||||
mesh = bpy.data.meshes.new(name='Plan/Annotation/PLAN_VIEW/' + guid)
|
||||
mesh = bpy.data.meshes.new(name="Plan/Annotation/PLAN_VIEW/" + guid)
|
||||
mesh.use_fake_user = True
|
||||
mesh.from_pydata(verts, edges, faces)
|
||||
|
||||
@@ -49,17 +69,17 @@ def add_object(self, context):
|
||||
verts = [
|
||||
Vector((0, 0, 0)),
|
||||
Vector((0, -self.depth, 0)),
|
||||
Vector((.04, -self.depth, 0)),
|
||||
Vector((.04, -self.depth+.04, 0)),
|
||||
Vector((.065, -self.depth+.04, 0)),
|
||||
Vector((.065, 0, 0)),
|
||||
Vector((0.04, -self.depth, 0)),
|
||||
Vector((0.04, -self.depth + 0.04, 0)),
|
||||
Vector((0.065, -self.depth + 0.04, 0)),
|
||||
Vector((0.065, 0, 0)),
|
||||
]
|
||||
edges = []
|
||||
faces = [[0, 1, 2, 3, 4, 5]]
|
||||
mesh = bpy.data.meshes.new(name="Dumb Door Profile")
|
||||
mesh.from_pydata(verts, edges, faces)
|
||||
obj = object_data_add(context, mesh, operator=self)
|
||||
bpy.ops.object.convert(target='CURVE')
|
||||
bpy.ops.object.convert(target="CURVE")
|
||||
|
||||
# Door lining sweep
|
||||
verts = [
|
||||
@@ -70,99 +90,97 @@ def add_object(self, context):
|
||||
]
|
||||
edges = [[0, 1], [1, 2], [2, 3]]
|
||||
faces = []
|
||||
mesh = bpy.data.meshes.new(name='Dumb Door')
|
||||
mesh = bpy.data.meshes.new(name="Dumb Door")
|
||||
mesh.from_pydata(verts, edges, faces)
|
||||
obj2 = object_data_add(context, mesh, operator=self)
|
||||
bpy.ops.object.convert(target='CURVE')
|
||||
bpy.ops.object.convert(target="CURVE")
|
||||
|
||||
obj2.data.dimensions = '2D'
|
||||
obj2.data.dimensions = "2D"
|
||||
obj2.data.bevel_object = obj
|
||||
|
||||
obj2.rotation_euler[0] = math.pi/2
|
||||
bpy.ops.object.convert(target='MESH')
|
||||
obj2.rotation_euler[0] = math.pi / 2
|
||||
bpy.ops.object.convert(target="MESH")
|
||||
bpy.ops.object.transform_apply(location=False)
|
||||
bpy.data.objects.remove(obj, do_unlink=True)
|
||||
|
||||
# Door panel
|
||||
verts = [
|
||||
Vector((.045, self.depth, 0)),
|
||||
Vector((.045, self.depth-.035, 0)),
|
||||
Vector((self.overall_width-.045, self.depth-.035, 0)),
|
||||
Vector((self.overall_width-.045, self.depth, 0)),
|
||||
Vector((0.045, self.depth, 0)),
|
||||
Vector((0.045, self.depth - 0.035, 0)),
|
||||
Vector((self.overall_width - 0.045, self.depth - 0.035, 0)),
|
||||
Vector((self.overall_width - 0.045, self.depth, 0)),
|
||||
]
|
||||
edges = []
|
||||
faces = [[0, 1, 2, 3]]
|
||||
mesh = bpy.data.meshes.new(name="Dumb Door Panel")
|
||||
mesh.from_pydata(verts, edges, faces)
|
||||
obj3 = object_data_add(context, mesh, operator=self)
|
||||
modifier = obj3.modifiers.new('Panel Height', 'SOLIDIFY')
|
||||
modifier = obj3.modifiers.new("Panel Height", "SOLIDIFY")
|
||||
modifier.offset = 1
|
||||
modifier.thickness = self.overall_height-.045
|
||||
bpy.ops.object.convert(target='MESH')
|
||||
modifier.thickness = self.overall_height - 0.045
|
||||
bpy.ops.object.convert(target="MESH")
|
||||
|
||||
ctx = bpy.context.copy()
|
||||
ctx['active_object'] = obj2
|
||||
ctx['selected_editable_objects'] = [obj2, obj3]
|
||||
ctx["active_object"] = obj2
|
||||
ctx["selected_editable_objects"] = [obj2, obj3]
|
||||
bpy.ops.object.join(ctx)
|
||||
|
||||
# Door Opening
|
||||
verts = [
|
||||
Vector((0, -.1, -.1)),
|
||||
Vector((0, self.depth+.1, -.1)),
|
||||
Vector((self.overall_width, self.depth+.1, -.1)),
|
||||
Vector((self.overall_width, -.1, -.1)),
|
||||
Vector((0, -0.1, -0.1)),
|
||||
Vector((0, self.depth + 0.1, -0.1)),
|
||||
Vector((self.overall_width, self.depth + 0.1, -0.1)),
|
||||
Vector((self.overall_width, -0.1, -0.1)),
|
||||
]
|
||||
edges = []
|
||||
faces = [[0, 1, 2, 3]]
|
||||
mesh = bpy.data.meshes.new(name="Dumb Door Opening")
|
||||
mesh.from_pydata(verts, edges, faces)
|
||||
obj4 = object_data_add(context, mesh, operator=self)
|
||||
modifier = obj4.modifiers.new('Panel Height', 'SOLIDIFY')
|
||||
modifier = obj4.modifiers.new("Panel Height", "SOLIDIFY")
|
||||
modifier.offset = -1
|
||||
modifier.thickness = self.overall_height+.1
|
||||
bpy.ops.object.convert(target='MESH')
|
||||
obj4.display_type = 'WIRE'
|
||||
modifier.thickness = self.overall_height + 0.1
|
||||
bpy.ops.object.convert(target="MESH")
|
||||
obj4.display_type = "WIRE"
|
||||
obj4.parent = obj2
|
||||
obj4.matrix_parent_inverse = obj2.matrix_world.inverted()
|
||||
obj4.hide_render = True
|
||||
obj4.name = 'IfcOpeningElement/Dumb Door Opening'
|
||||
obj4.name = "IfcOpeningElement/Dumb Door Opening"
|
||||
attribute = obj4.BIMObjectProperties.attributes.add()
|
||||
attribute.name = 'PredefinedType'
|
||||
attribute.string_value = 'OPENING'
|
||||
attribute.name = "PredefinedType"
|
||||
attribute.string_value = "OPENING"
|
||||
|
||||
obj2.name = 'IfcDoor/Dumb Door'
|
||||
obj2.name = "IfcDoor/Dumb Door"
|
||||
attribute = obj2.BIMObjectProperties.attributes.add()
|
||||
attribute.name = 'PredefinedType'
|
||||
attribute.string_value = 'DOOR'
|
||||
obj2.data.name = 'Model/Body/MODEL_VIEW/' + guid
|
||||
attribute.name = "PredefinedType"
|
||||
attribute.string_value = "DOOR"
|
||||
obj2.data.name = "Model/Body/MODEL_VIEW/" + guid
|
||||
obj2.data.use_fake_user = True
|
||||
|
||||
rep = obj2.BIMObjectProperties.representation_contexts.add()
|
||||
rep.context = 'Model'
|
||||
rep.name = 'Body'
|
||||
rep.target_view = 'MODEL_VIEW'
|
||||
rep.context = "Model"
|
||||
rep.name = "Body"
|
||||
rep.target_view = "MODEL_VIEW"
|
||||
|
||||
rep = obj2.BIMObjectProperties.representation_contexts.add()
|
||||
rep.context = 'Plan'
|
||||
rep.name = 'Annotation'
|
||||
rep.target_view = 'PLAN_VIEW'
|
||||
rep.context = "Plan"
|
||||
rep.name = "Annotation"
|
||||
rep.target_view = "PLAN_VIEW"
|
||||
|
||||
|
||||
class BIM_OT_add_object(Operator, AddObjectHelper):
|
||||
bl_idname = "mesh.add_door"
|
||||
bl_label = "Dumb Door"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
overall_width: FloatProperty(name='Overall Width', default=.85)
|
||||
overall_height: FloatProperty(name='Overall Height', default=2.1)
|
||||
depth: FloatProperty(name='Depth', default=.2)
|
||||
overall_width: FloatProperty(name="Overall Width", default=0.85)
|
||||
overall_height: FloatProperty(name="Overall Height", default=2.1)
|
||||
depth: FloatProperty(name="Depth", default=0.2)
|
||||
|
||||
def execute(self, context):
|
||||
add_object(self, context)
|
||||
return {'FINISHED'}
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
def add_object_button(self, context):
|
||||
self.layout.operator(
|
||||
BIM_OT_add_object.bl_idname,
|
||||
icon='PLUGIN')
|
||||
self.layout.operator(BIM_OT_add_object.bl_idname, icon="PLUGIN")
|
||||
|
||||
@@ -5,70 +5,74 @@ 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):
|
||||
obj = object_data_add(context, None, operator=self)
|
||||
obj.name = 'IfcGrid/Grid'
|
||||
name = obj.name.split('/')[1]
|
||||
obj.name = "IfcGrid/Grid"
|
||||
name = obj.name.split("/")[1]
|
||||
|
||||
default_collection = obj.users_collection[0]
|
||||
default_collection.objects.unlink(obj)
|
||||
|
||||
collection = bpy.data.collections.new('IfcGrid/' + name)
|
||||
collection = bpy.data.collections.new("IfcGrid/" + name)
|
||||
bpy.context.view_layer.active_layer_collection.collection.children.link(collection)
|
||||
collection.objects.link(obj)
|
||||
|
||||
axes_collection = bpy.data.collections.new('UAxes')
|
||||
axes_collection = bpy.data.collections.new("UAxes")
|
||||
collection.children.link(axes_collection)
|
||||
for i in range(0, self.total_u):
|
||||
verts = [Vector((-2, i*self.u_spacing, 0)), Vector((((self.total_v-1)*self.v_spacing)+2, i*self.u_spacing, 0))]
|
||||
verts = [
|
||||
Vector((-2, i * self.u_spacing, 0)),
|
||||
Vector((((self.total_v - 1) * self.v_spacing) + 2, i * self.u_spacing, 0)),
|
||||
]
|
||||
edges = [[0, 1]]
|
||||
faces = []
|
||||
mesh = bpy.data.meshes.new(name="Grid Axis")
|
||||
mesh.from_pydata(verts, edges, faces)
|
||||
obj = object_data_add(context, mesh, operator=self)
|
||||
tag = chr(ord('A')+i)
|
||||
obj.name = 'IfcGridAxis/' + tag
|
||||
tag = chr(ord("A") + i)
|
||||
obj.name = "IfcGridAxis/" + tag
|
||||
default_collection.objects.unlink(obj)
|
||||
axes_collection.objects.link(obj)
|
||||
attribute = obj.BIMObjectProperties.attributes.add()
|
||||
attribute.name = 'AxisTag'
|
||||
attribute.name = "AxisTag"
|
||||
attribute.string_value = tag
|
||||
|
||||
axes_collection = bpy.data.collections.new('VAxes')
|
||||
axes_collection = bpy.data.collections.new("VAxes")
|
||||
collection.children.link(axes_collection)
|
||||
for i in range(0, self.total_v):
|
||||
verts = [Vector((i*self.v_spacing, -2, 0)), Vector((i*self.v_spacing, ((self.total_u-1)*self.u_spacing)+2, 0))]
|
||||
verts = [
|
||||
Vector((i * self.v_spacing, -2, 0)),
|
||||
Vector((i * self.v_spacing, ((self.total_u - 1) * self.u_spacing) + 2, 0)),
|
||||
]
|
||||
edges = [[0, 1]]
|
||||
faces = []
|
||||
mesh = bpy.data.meshes.new(name="Grid Axis")
|
||||
mesh.from_pydata(verts, edges, faces)
|
||||
obj = object_data_add(context, mesh, operator=self)
|
||||
tag = str(i+1).zfill(2)
|
||||
obj.name = 'IfcGridAxis/' + tag
|
||||
tag = str(i + 1).zfill(2)
|
||||
obj.name = "IfcGridAxis/" + tag
|
||||
default_collection.objects.unlink(obj)
|
||||
axes_collection.objects.link(obj)
|
||||
attribute = obj.BIMObjectProperties.attributes.add()
|
||||
attribute.name = 'AxisTag'
|
||||
attribute.name = "AxisTag"
|
||||
attribute.string_value = tag
|
||||
|
||||
|
||||
|
||||
class BIM_OT_add_object(Operator, AddObjectHelper):
|
||||
bl_idname = "mesh.add_grid"
|
||||
bl_label = "Grid"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
u_spacing: FloatProperty(name='U Spacing', default=10)
|
||||
total_u: IntProperty(name='Number of U Grids', default=3)
|
||||
v_spacing: FloatProperty(name='V Spacing', default=10)
|
||||
total_v: IntProperty(name='Number of V Grids', default=3)
|
||||
u_spacing: FloatProperty(name="U Spacing", default=10)
|
||||
total_u: IntProperty(name="Number of U Grids", default=3)
|
||||
v_spacing: FloatProperty(name="V Spacing", default=10)
|
||||
total_v: IntProperty(name="Number of V Grids", default=3)
|
||||
|
||||
def execute(self, context):
|
||||
add_object(self, context)
|
||||
return {'FINISHED'}
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
def add_object_button(self, context):
|
||||
self.layout.operator(
|
||||
BIM_OT_add_object.bl_idname,
|
||||
icon='PLUGIN')
|
||||
self.layout.operator(BIM_OT_add_object.bl_idname, icon="PLUGIN")
|
||||
|
||||
@@ -5,6 +5,7 @@ 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)
|
||||
@@ -15,26 +16,24 @@ def add_object(self, context):
|
||||
bm.to_mesh(mesh)
|
||||
bm.free()
|
||||
obj = object_data_add(context, mesh, operator=self)
|
||||
obj.name = 'IfcOpening/Dumb Opening'
|
||||
obj.display_type = 'WIRE'
|
||||
obj.name = "IfcOpening/Dumb Opening"
|
||||
obj.display_type = "WIRE"
|
||||
attribute = obj.BIMObjectProperties.attributes.add()
|
||||
attribute.name = 'PredefinedType'
|
||||
attribute.string_value = 'OPENING'
|
||||
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'}
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
size: FloatProperty(name='Size', default=2)
|
||||
size: FloatProperty(name="Size", default=2)
|
||||
|
||||
def execute(self, context):
|
||||
add_object(self, context)
|
||||
return {'FINISHED'}
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
def add_object_button(self, context):
|
||||
self.layout.operator(
|
||||
BIM_OT_add_object.bl_idname,
|
||||
icon='PLUGIN')
|
||||
self.layout.operator(BIM_OT_add_object.bl_idname, icon="PLUGIN")
|
||||
|
||||
@@ -4,6 +4,7 @@ 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):
|
||||
verts = [
|
||||
Vector((0, 0, 0)),
|
||||
@@ -17,31 +18,29 @@ def add_object(self, context):
|
||||
mesh = bpy.data.meshes.new(name="Dumb Slab")
|
||||
mesh.from_pydata(verts, edges, faces)
|
||||
obj = object_data_add(context, mesh, operator=self)
|
||||
modifier = obj.modifiers.new('Slab Depth', 'SOLIDIFY')
|
||||
modifier = obj.modifiers.new("Slab Depth", "SOLIDIFY")
|
||||
modifier.use_even_offset = True
|
||||
modifier.offset = 1
|
||||
modifier.thickness = self.depth
|
||||
obj.name = 'IfcSlab/Dumb Slab'
|
||||
obj.name = "IfcSlab/Dumb Slab"
|
||||
attribute = obj.BIMObjectProperties.attributes.add()
|
||||
attribute.name = 'PredefinedType'
|
||||
attribute.string_value = 'FLOOR'
|
||||
attribute.name = "PredefinedType"
|
||||
attribute.string_value = "FLOOR"
|
||||
|
||||
|
||||
class BIM_OT_add_object(Operator, AddObjectHelper):
|
||||
bl_idname = "mesh.add_slab"
|
||||
bl_label = "Dumb Slab"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
length: FloatProperty(name='Length', default=2)
|
||||
width: FloatProperty(name='Width', default=2)
|
||||
depth: FloatProperty(name='Depth', default=.2)
|
||||
length: FloatProperty(name="Length", default=2)
|
||||
width: FloatProperty(name="Width", default=2)
|
||||
depth: FloatProperty(name="Depth", default=0.2)
|
||||
|
||||
def execute(self, context):
|
||||
add_object(self, context)
|
||||
return {'FINISHED'}
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
def add_object_button(self, context):
|
||||
self.layout.operator(
|
||||
BIM_OT_add_object.bl_idname,
|
||||
icon='PLUGIN')
|
||||
self.layout.operator(BIM_OT_add_object.bl_idname, icon="PLUGIN")
|
||||
|
||||
@@ -4,6 +4,7 @@ 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
|
||||
@@ -19,11 +20,11 @@ def add_object(self, context):
|
||||
mesh = bpy.data.meshes.new(name="Dumb Stair")
|
||||
mesh.from_pydata(verts, edges, faces)
|
||||
obj = object_data_add(context, mesh, operator=self)
|
||||
modifier = obj.modifiers.new('Stair Width', 'SOLIDIFY')
|
||||
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 = obj.modifiers.new("Stair Treads", "ARRAY")
|
||||
modifier.relative_offset_displace[0] = 0
|
||||
modifier.relative_offset_displace[1] = 1
|
||||
modifier.use_constant_offset = True
|
||||
@@ -31,31 +32,29 @@ def add_object(self, context):
|
||||
modifier.count = self.number_of_treads
|
||||
self.riser_height = self.height / self.number_of_treads
|
||||
self.length = self.number_of_treads * self.tread_length
|
||||
obj.name = 'IfcStairFlight/Dumb Stair'
|
||||
obj.name = "IfcStairFlight/Dumb Stair"
|
||||
attribute = obj.BIMObjectProperties.attributes.add()
|
||||
attribute.name = 'PredefinedType'
|
||||
attribute.string_value = 'STRAIGHT'
|
||||
attribute.name = "PredefinedType"
|
||||
attribute.string_value = "STRAIGHT"
|
||||
|
||||
|
||||
class BIM_OT_add_object(Operator, AddObjectHelper):
|
||||
bl_idname = "mesh.add_stair"
|
||||
bl_label = "Dumb Stair"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
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')
|
||||
width: FloatProperty(name="Width", default=1.1)
|
||||
height: FloatProperty(name="Height", default=1)
|
||||
tread_depth: FloatProperty(name="Tread Depth", default=0.2)
|
||||
number_of_treads: IntProperty(name="Number of Treads (Goings)", default=6)
|
||||
tread_length: FloatProperty(name="Tread Length (Going)", default=0.25)
|
||||
riser_height: FloatProperty(name="*Calculated* Riser Height")
|
||||
length: FloatProperty(name="*Calculated* Length")
|
||||
|
||||
def execute(self, context):
|
||||
add_object(self, context)
|
||||
return {'FINISHED'}
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
def add_object_button(self, context):
|
||||
self.layout.operator(
|
||||
BIM_OT_add_object.bl_idname,
|
||||
icon='PLUGIN')
|
||||
self.layout.operator(BIM_OT_add_object.bl_idname, icon="PLUGIN")
|
||||
|
||||
@@ -4,6 +4,7 @@ from bpy.props import FloatVectorProperty, FloatProperty, BoolProperty
|
||||
from bpy_extras.object_utils import AddObjectHelper, object_data_add
|
||||
from mathutils import Vector
|
||||
|
||||
|
||||
def add_object(self, context):
|
||||
if self.use_plane:
|
||||
verts = [
|
||||
@@ -26,7 +27,7 @@ def add_object(self, context):
|
||||
mesh.from_pydata(verts, edges, faces)
|
||||
obj = object_data_add(context, mesh, operator=self)
|
||||
if not self.use_plane:
|
||||
modifier = obj.modifiers.new('Wall Height', 'SCREW')
|
||||
modifier = obj.modifiers.new("Wall Height", "SCREW")
|
||||
modifier.angle = 0
|
||||
modifier.screw_offset = self.height
|
||||
modifier.use_smooth_shade = False
|
||||
@@ -34,31 +35,29 @@ def add_object(self, context):
|
||||
modifier.use_normal_flip = True
|
||||
modifier.steps = 1
|
||||
modifier.render_steps = 1
|
||||
modifier = obj.modifiers.new('Wall Width', 'SOLIDIFY')
|
||||
modifier = obj.modifiers.new("Wall Width", "SOLIDIFY")
|
||||
modifier.use_even_offset = True
|
||||
modifier.thickness = self.width
|
||||
obj.name = 'IfcWall/Dumb Wall'
|
||||
obj.name = "IfcWall/Dumb Wall"
|
||||
attribute = obj.BIMObjectProperties.attributes.add()
|
||||
attribute.name = 'PredefinedType'
|
||||
attribute.string_value = 'STANDARD'
|
||||
attribute.name = "PredefinedType"
|
||||
attribute.string_value = "STANDARD"
|
||||
|
||||
|
||||
class BIM_OT_add_object(Operator, AddObjectHelper):
|
||||
bl_idname = "mesh.add_wall"
|
||||
bl_label = "Dumb Wall"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
height: FloatProperty(name='Height', default=3)
|
||||
length: FloatProperty(name='Length', default=1)
|
||||
width: FloatProperty(name='Width', default=.2)
|
||||
use_plane: BoolProperty(name='Use Plane', default=False)
|
||||
height: FloatProperty(name="Height", default=3)
|
||||
length: FloatProperty(name="Length", default=1)
|
||||
width: FloatProperty(name="Width", default=0.2)
|
||||
use_plane: BoolProperty(name="Use Plane", default=False)
|
||||
|
||||
def execute(self, context):
|
||||
add_object(self, context)
|
||||
return {'FINISHED'}
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
def add_object_button(self, context):
|
||||
self.layout.operator(
|
||||
BIM_OT_add_object.bl_idname,
|
||||
icon='PLUGIN')
|
||||
self.layout.operator(BIM_OT_add_object.bl_idname, icon="PLUGIN")
|
||||
|
||||
@@ -6,39 +6,50 @@ 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):
|
||||
guid = ifcopenshell.guid.new()
|
||||
leaf_width = self.overall_width-0.045-0.045
|
||||
leaf_width = self.overall_width - 0.045 - 0.045
|
||||
verts = [
|
||||
# Left lining
|
||||
Vector((0, 0, 0)),
|
||||
Vector((0, self.depth, 0)),
|
||||
Vector((.04, self.depth, 0)),
|
||||
Vector((.04, 0, 0)),
|
||||
Vector((0.04, self.depth, 0)),
|
||||
Vector((0.04, 0, 0)),
|
||||
# Right lining
|
||||
Vector((self.overall_width, 0, 0)),
|
||||
Vector((self.overall_width, self.depth, 0)),
|
||||
Vector((self.overall_width-.04, self.depth, 0)),
|
||||
Vector((self.overall_width-.04, 0, 0)),
|
||||
Vector((self.overall_width - 0.04, self.depth, 0)),
|
||||
Vector((self.overall_width - 0.04, 0, 0)),
|
||||
# Bottom lining
|
||||
Vector((0, 0, 0)),
|
||||
Vector((self.overall_width, 0, 0)),
|
||||
Vector((0, self.depth, 0)),
|
||||
Vector((self.overall_width, self.depth, 0)),
|
||||
# Window panel
|
||||
Vector((.04, (self.depth/2)+.005, 0)),
|
||||
Vector((.04, (self.depth/2)-.005, 0)),
|
||||
Vector((self.overall_width-.04, (self.depth/2)-.005, 0)),
|
||||
Vector((self.overall_width-.04, (self.depth/2)+.005, 0)),
|
||||
Vector((0.04, (self.depth / 2) + 0.005, 0)),
|
||||
Vector((0.04, (self.depth / 2) - 0.005, 0)),
|
||||
Vector((self.overall_width - 0.04, (self.depth / 2) - 0.005, 0)),
|
||||
Vector((self.overall_width - 0.04, (self.depth / 2) + 0.005, 0)),
|
||||
]
|
||||
edges = [
|
||||
[0, 1], [1, 2], [2, 3], [3, 0], # Left lining
|
||||
[4, 5], [5, 6], [6, 7], [7, 4], # Right lining
|
||||
[8, 9], [10, 11], # Bottom lining
|
||||
[12, 13], [13, 14], [14, 15], [15, 12], # Window panel
|
||||
[0, 1],
|
||||
[1, 2],
|
||||
[2, 3],
|
||||
[3, 0], # Left lining
|
||||
[4, 5],
|
||||
[5, 6],
|
||||
[6, 7],
|
||||
[7, 4], # Right lining
|
||||
[8, 9],
|
||||
[10, 11], # Bottom lining
|
||||
[12, 13],
|
||||
[13, 14],
|
||||
[14, 15],
|
||||
[15, 12], # Window panel
|
||||
]
|
||||
faces = []
|
||||
mesh = bpy.data.meshes.new(name='Plan/Annotation/PLAN_VIEW/' + guid)
|
||||
mesh = bpy.data.meshes.new(name="Plan/Annotation/PLAN_VIEW/" + guid)
|
||||
mesh.use_fake_user = True
|
||||
mesh.from_pydata(verts, edges, faces)
|
||||
|
||||
@@ -46,15 +57,15 @@ def add_object(self, context):
|
||||
verts = [
|
||||
Vector((0, 0, 0)),
|
||||
Vector((0, -self.depth, 0)),
|
||||
Vector((.04, -self.depth, 0)),
|
||||
Vector((.04, 0, 0)),
|
||||
Vector((0.04, -self.depth, 0)),
|
||||
Vector((0.04, 0, 0)),
|
||||
]
|
||||
edges = []
|
||||
faces = [[0, 1, 2, 3]]
|
||||
mesh = bpy.data.meshes.new(name="Dumb Window Profile")
|
||||
mesh.from_pydata(verts, edges, faces)
|
||||
obj = object_data_add(context, mesh, operator=self)
|
||||
bpy.ops.object.convert(target='CURVE')
|
||||
bpy.ops.object.convert(target="CURVE")
|
||||
|
||||
# Window lining sweep
|
||||
verts = [
|
||||
@@ -68,97 +79,95 @@ def add_object(self, context):
|
||||
mesh = bpy.data.meshes.new(name="Dumb Window")
|
||||
mesh.from_pydata(verts, edges, faces)
|
||||
obj2 = object_data_add(context, mesh, operator=self)
|
||||
bpy.ops.object.convert(target='CURVE')
|
||||
bpy.ops.object.convert(target="CURVE")
|
||||
obj2.data.splines[0].use_cyclic_u = True
|
||||
|
||||
obj2.data.dimensions = '2D'
|
||||
obj2.data.dimensions = "2D"
|
||||
obj2.data.bevel_object = obj
|
||||
|
||||
obj2.rotation_euler[0] = math.pi/2
|
||||
bpy.ops.object.convert(target='MESH')
|
||||
obj2.rotation_euler[0] = math.pi / 2
|
||||
bpy.ops.object.convert(target="MESH")
|
||||
bpy.ops.object.transform_apply(location=False)
|
||||
bpy.data.objects.remove(obj, do_unlink=True)
|
||||
|
||||
# Window panel
|
||||
verts = [
|
||||
Vector((.04, (self.depth/2)+.005, .04)),
|
||||
Vector((.04, (self.depth/2)-.005, .04)),
|
||||
Vector((self.overall_width-.04, (self.depth/2)-.005, .04)),
|
||||
Vector((self.overall_width-.04, (self.depth/2)+.005, .04)),
|
||||
Vector((0.04, (self.depth / 2) + 0.005, 0.04)),
|
||||
Vector((0.04, (self.depth / 2) - 0.005, 0.04)),
|
||||
Vector((self.overall_width - 0.04, (self.depth / 2) - 0.005, 0.04)),
|
||||
Vector((self.overall_width - 0.04, (self.depth / 2) + 0.005, 0.04)),
|
||||
]
|
||||
edges = []
|
||||
faces = [[0, 1, 2, 3]]
|
||||
mesh = bpy.data.meshes.new(name="Dumb Window Panel")
|
||||
mesh.from_pydata(verts, edges, faces)
|
||||
obj3 = object_data_add(context, mesh, operator=self)
|
||||
modifier = obj3.modifiers.new('Panel Height', 'SOLIDIFY')
|
||||
modifier = obj3.modifiers.new("Panel Height", "SOLIDIFY")
|
||||
modifier.offset = 1
|
||||
modifier.thickness = self.overall_height-.08
|
||||
bpy.ops.object.convert(target='MESH')
|
||||
modifier.thickness = self.overall_height - 0.08
|
||||
bpy.ops.object.convert(target="MESH")
|
||||
|
||||
ctx = bpy.context.copy()
|
||||
ctx['active_object'] = obj2
|
||||
ctx['selected_editable_objects'] = [obj2, obj3]
|
||||
ctx["active_object"] = obj2
|
||||
ctx["selected_editable_objects"] = [obj2, obj3]
|
||||
bpy.ops.object.join(ctx)
|
||||
|
||||
# Window Opening
|
||||
verts = [
|
||||
Vector((0, -.1, 0)),
|
||||
Vector((0, self.depth+.1, 0)),
|
||||
Vector((self.overall_width, self.depth+.1, 0)),
|
||||
Vector((self.overall_width, -.1, 0)),
|
||||
Vector((0, -0.1, 0)),
|
||||
Vector((0, self.depth + 0.1, 0)),
|
||||
Vector((self.overall_width, self.depth + 0.1, 0)),
|
||||
Vector((self.overall_width, -0.1, 0)),
|
||||
]
|
||||
edges = []
|
||||
faces = [[0, 1, 2, 3]]
|
||||
mesh = bpy.data.meshes.new(name="Dumb Window Opening")
|
||||
mesh.from_pydata(verts, edges, faces)
|
||||
obj4 = object_data_add(context, mesh, operator=self)
|
||||
modifier = obj4.modifiers.new('Panel Height', 'SOLIDIFY')
|
||||
modifier = obj4.modifiers.new("Panel Height", "SOLIDIFY")
|
||||
modifier.offset = -1
|
||||
modifier.thickness = self.overall_height
|
||||
bpy.ops.object.convert(target='MESH')
|
||||
obj4.display_type = 'WIRE'
|
||||
bpy.ops.object.convert(target="MESH")
|
||||
obj4.display_type = "WIRE"
|
||||
obj4.parent = obj2
|
||||
obj4.matrix_parent_inverse = obj2.matrix_world.inverted()
|
||||
obj4.hide_render = True
|
||||
obj4.name = 'IfcOpeningElement/Dumb Window Opening'
|
||||
obj4.name = "IfcOpeningElement/Dumb Window Opening"
|
||||
attribute = obj4.BIMObjectProperties.attributes.add()
|
||||
attribute.name = 'PredefinedType'
|
||||
attribute.string_value = 'OPENING'
|
||||
attribute.name = "PredefinedType"
|
||||
attribute.string_value = "OPENING"
|
||||
|
||||
obj2.name = 'IfcWindow/Dumb Window'
|
||||
obj2.name = "IfcWindow/Dumb Window"
|
||||
attribute = obj2.BIMObjectProperties.attributes.add()
|
||||
attribute.name = 'PredefinedType'
|
||||
attribute.string_value = 'WINDOW'
|
||||
obj2.data.name = 'Model/Body/MODEL_VIEW/' + guid
|
||||
attribute.name = "PredefinedType"
|
||||
attribute.string_value = "WINDOW"
|
||||
obj2.data.name = "Model/Body/MODEL_VIEW/" + guid
|
||||
obj2.data.use_fake_user = True
|
||||
|
||||
rep = obj2.BIMObjectProperties.representation_contexts.add()
|
||||
rep.context = 'Model'
|
||||
rep.name = 'Body'
|
||||
rep.target_view = 'MODEL_VIEW'
|
||||
rep.context = "Model"
|
||||
rep.name = "Body"
|
||||
rep.target_view = "MODEL_VIEW"
|
||||
|
||||
rep = obj2.BIMObjectProperties.representation_contexts.add()
|
||||
rep.context = 'Plan'
|
||||
rep.name = 'Annotation'
|
||||
rep.target_view = 'PLAN_VIEW'
|
||||
rep.context = "Plan"
|
||||
rep.name = "Annotation"
|
||||
rep.target_view = "PLAN_VIEW"
|
||||
|
||||
|
||||
class BIM_OT_add_object(Operator, AddObjectHelper):
|
||||
bl_idname = "mesh.add_window"
|
||||
bl_label = "Dumb Window"
|
||||
bl_options = {'REGISTER', 'UNDO'}
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
overall_width: FloatProperty(name='Overall Width', default=.7)
|
||||
overall_height: FloatProperty(name='Overall Height', default=1)
|
||||
depth: FloatProperty(name='Depth', default=.1)
|
||||
overall_width: FloatProperty(name="Overall Width", default=0.7)
|
||||
overall_height: FloatProperty(name="Overall Height", default=1)
|
||||
depth: FloatProperty(name="Depth", default=0.1)
|
||||
|
||||
def execute(self, context):
|
||||
add_object(self, context)
|
||||
return {'FINISHED'}
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
def add_object_button(self, context):
|
||||
self.layout.operator(
|
||||
BIM_OT_add_object.bl_idname,
|
||||
icon='PLUGIN')
|
||||
self.layout.operator(BIM_OT_add_object.bl_idname, icon="PLUGIN")
|
||||
|
||||
Reference in New Issue
Block a user