black ifcblenderexport

This commit is contained in:
htlcnn
2020-11-01 20:08:48 +07:00
committed by Dion Moult
parent 286c77e3b0
commit 163075a821
36 changed files with 7032 additions and 6232 deletions
@@ -1,15 +1,16 @@
import json
import requests
class Api:
def login(self, username, password):
data = {
'username': username,
'password': password,
"username": username,
"password": password,
}
response_data = self.post_request('get-token', data, False)
if 'token' in response_data:
self.token = str(response_data['token'])
response_data = self.post_request("get-token", data, False)
if "token" in response_data:
self.token = str(response_data["token"])
return self.token
def post_request(self, path, data, use_token=True):
@@ -25,17 +26,16 @@ class Api:
return self._handle_response(response)
def _api_url(self, path):
return 'https://app.covetool.com/api/' + path + '/'
return "https://app.covetool.com/api/" + path + "/"
def _headers(self, use_token):
headers = {}
if use_token:
headers['Authorization'] = 'Token ' + self.token
headers["Authorization"] = "Token " + self.token
return headers
def _handle_response(self, response):
if response.ok:
return response.json()
else:
return {'result': 'error'}
return {"result": "error"}
@@ -6,98 +6,106 @@ from .api import Api
api = Api()
class Login(bpy.types.Operator):
bl_idname = 'bim.covetool_login'
bl_label = 'Login to cove.tool'
bl_idname = "bim.covetool_login"
bl_label = "Login to cove.tool"
def execute(self, context):
token = api.login(
bpy.context.scene.CoveToolProperties.username,
bpy.context.scene.CoveToolProperties.password)
token = api.login(bpy.context.scene.CoveToolProperties.username, bpy.context.scene.CoveToolProperties.password)
if token:
bpy.context.scene.CoveToolProperties.token = token
projects = api.get_request('projects')
projects = api.get_request("projects")
for project in projects:
new_project = bpy.context.scene.CoveToolProperties.projects.add()
new_project.name = project['name']
new_project.run_set = project['run_set'][0]
new_project.url = project['url']
new_project.name = project["name"]
new_project.run_set = project["run_set"][0]
new_project.url = project["url"]
else:
self.report({'ERROR'}, 'Login failed :(')
return {'FINISHED'}
self.report({"ERROR"}, "Login failed :(")
return {"FINISHED"}
class RunSimpleAnalysis(bpy.types.Operator):
bl_idname = 'bim.covetool_run_simple_analysis'
bl_label = 'Run Simple Analysis'
bl_idname = "bim.covetool_run_simple_analysis"
bl_label = "Run Simple Analysis"
def execute(self, context):
simple_analysis = bpy.context.scene.CoveToolProperties.simple_analysis
data = {
'run': bpy.context.scene.CoveToolProperties.projects[bpy.context.scene.CoveToolProperties.active_project_index].run_set,
'si_units': simple_analysis.si_units,
'building_height': simple_analysis.building_height,
'roof_area': simple_analysis.roof_area,
'floor_area': simple_analysis.floor_area,
'skylight_area': simple_analysis.skylight_area,
'wall_area_e': simple_analysis.wall_area_e,
'wall_area_ne': simple_analysis.wall_area_ne,
'wall_area_n': simple_analysis.wall_area_n,
'wall_area_nw': simple_analysis.wall_area_nw,
'wall_area_w': simple_analysis.wall_area_w,
'wall_area_sw': simple_analysis.wall_area_sw,
'wall_area_s': simple_analysis.wall_area_s,
'wall_area_se': simple_analysis.wall_area_se,
'window_area_e': simple_analysis.window_area_e,
'window_area_ne': simple_analysis.window_area_ne,
'window_area_n': simple_analysis.window_area_n,
'window_area_nw': simple_analysis.window_area_nw,
'window_area_w': simple_analysis.window_area_w,
'window_area_sw': simple_analysis.window_area_sw,
'window_area_s': simple_analysis.window_area_s,
'window_area_se': simple_analysis.window_area_se,
"run": bpy.context.scene.CoveToolProperties.projects[
bpy.context.scene.CoveToolProperties.active_project_index
].run_set,
"si_units": simple_analysis.si_units,
"building_height": simple_analysis.building_height,
"roof_area": simple_analysis.roof_area,
"floor_area": simple_analysis.floor_area,
"skylight_area": simple_analysis.skylight_area,
"wall_area_e": simple_analysis.wall_area_e,
"wall_area_ne": simple_analysis.wall_area_ne,
"wall_area_n": simple_analysis.wall_area_n,
"wall_area_nw": simple_analysis.wall_area_nw,
"wall_area_w": simple_analysis.wall_area_w,
"wall_area_sw": simple_analysis.wall_area_sw,
"wall_area_s": simple_analysis.wall_area_s,
"wall_area_se": simple_analysis.wall_area_se,
"window_area_e": simple_analysis.window_area_e,
"window_area_ne": simple_analysis.window_area_ne,
"window_area_n": simple_analysis.window_area_n,
"window_area_nw": simple_analysis.window_area_nw,
"window_area_w": simple_analysis.window_area_w,
"window_area_sw": simple_analysis.window_area_sw,
"window_area_s": simple_analysis.window_area_s,
"window_area_se": simple_analysis.window_area_se,
}
result = api.post_request('run-values', data)
covetool_results = bpy.data.texts.new('cove.tool Results')
result = api.post_request("run-values", data)
covetool_results = bpy.data.texts.new("cove.tool Results")
covetool_results.write(json.dumps(result, indent=4))
return {'FINISHED'}
return {"FINISHED"}
class RunAnalysis(bpy.types.Operator):
bl_idname = 'bim.covetool_run_analysis'
bl_label = 'Run Analysis'
bl_idname = "bim.covetool_run_analysis"
bl_label = "Run Analysis"
def execute(self, context):
self.inputs = {
'floors': [],
'walls': [],
'interior_walls': [],
'windows': [],
'skylights': [],
'roofs': [],
'shading_devices': []
"floors": [],
"walls": [],
"interior_walls": [],
"windows": [],
"skylights": [],
"roofs": [],
"shading_devices": [],
}
self.parse_objects()
data = {
'run': bpy.context.scene.CoveToolProperties.projects[bpy.context.scene.CoveToolProperties.active_project_index].run_set,
'source': 'BlenderBIM',
'rotation_angle': self.get_rotation_angle(),
**self.inputs
"run": bpy.context.scene.CoveToolProperties.projects[
bpy.context.scene.CoveToolProperties.active_project_index
].run_set,
"source": "BlenderBIM",
"rotation_angle": self.get_rotation_angle(),
**self.inputs,
}
result = api.post_request('run-values', data)
covetool_results = bpy.data.texts.new('cove.tool Results')
result = api.post_request("run-values", data)
covetool_results = bpy.data.texts.new("cove.tool Results")
covetool_results.write(json.dumps(result, indent=4))
return {'FINISHED'}
return {"FINISHED"}
def get_rotation_angle(self):
if not bpy.context.scene.BIMProperties.has_georeferencing \
or not bpy.context.scene.MapConversion.x_axis_abscissa \
or not bpy.context.scene.MapConversion.x_axis_ordinate:
if (
not bpy.context.scene.BIMProperties.has_georeferencing
or not bpy.context.scene.MapConversion.x_axis_abscissa
or not bpy.context.scene.MapConversion.x_axis_ordinate
):
return 0
rotation = -1 * degrees(atan2(
float(bpy.context.scene.MapConversion.x_axis_ordinate),
float(bpy.context.scene.MapConversion.x_axis_abscissa)))
rotation = -1 * degrees(
atan2(
float(bpy.context.scene.MapConversion.x_axis_ordinate),
float(bpy.context.scene.MapConversion.x_axis_abscissa),
)
)
if rotation < 0:
rotation = 360 - rotation
return rotation
@@ -108,86 +116,82 @@ class RunAnalysis(bpy.types.Operator):
if not covetool_category:
continue
if not self.has_triangulate_modifier(obj):
obj.modifiers.new(name='Triangulate', type='TRIANGULATE')
obj.modifiers.new(name="Triangulate", type="TRIANGULATE")
mesh = obj.evaluated_get(bpy.context.evaluated_depsgraph_get()).to_mesh()
meshes = {}
for polygon in mesh.polygons:
normal = '{}|{}|{}'.format(
round(polygon.normal[0], 2),
round(polygon.normal[1], 2),
round(polygon.normal[2], 2))
meshes.setdefault(normal, {
'Mesh': {
'vertex_indices': {},
'Vertices': [],
'Triangles': []
normal = "{}|{}|{}".format(
round(polygon.normal[0], 2), round(polygon.normal[1], 2), round(polygon.normal[2], 2)
)
meshes.setdefault(
normal,
{
"Mesh": {"vertex_indices": {}, "Vertices": [], "Triangles": []},
"Center": {},
"Normal": {
"X": round(polygon.normal[0], 2),
"Y": round(polygon.normal[1], 2),
"Z": round(polygon.normal[2], 2),
},
},
'Center': {},
'Normal': {
'X': round(polygon.normal[0], 2),
'Y': round(polygon.normal[1], 2),
'Z': round(polygon.normal[2], 2)
}
})
)
for vertex in polygon.vertices:
global_vertex = obj.matrix_world @ mesh.vertices[vertex].co
meshes[normal]['Mesh']['vertex_indices'][vertex] = {
'X': global_vertex[0] * 3.28084, # Covetools require feet
'Y': global_vertex[1] * 3.28084,
'Z': global_vertex[2] * 3.28084
meshes[normal]["Mesh"]["vertex_indices"][vertex] = {
"X": global_vertex[0] * 3.28084, # Covetools require feet
"Y": global_vertex[1] * 3.28084,
"Z": global_vertex[2] * 3.28084,
}
meshes[normal]['Mesh']['Triangles'].append([
polygon.vertices[0],
polygon.vertices[1],
polygon.vertices[2]
])
meshes[normal]["Mesh"]["Triangles"].append(
[polygon.vertices[0], polygon.vertices[1], polygon.vertices[2]]
)
for normal, mesh in meshes.items():
sorted_keys = sorted(mesh['Mesh']['vertex_indices'])
mesh['Mesh']['Vertices'] = [mesh['Mesh']['vertex_indices'][k] for k in sorted_keys]
for triangle in mesh['Mesh']['Triangles']:
sorted_keys = sorted(mesh["Mesh"]["vertex_indices"])
mesh["Mesh"]["Vertices"] = [mesh["Mesh"]["vertex_indices"][k] for k in sorted_keys]
for triangle in mesh["Mesh"]["Triangles"]:
triangle[0] = sorted_keys.index(triangle[0])
triangle[1] = sorted_keys.index(triangle[1])
triangle[2] = sorted_keys.index(triangle[2])
mesh['Center'] = mesh['Mesh']['Vertices'][0] # Not correct, but just for now
del mesh['Mesh']['vertex_indices']
mesh["Center"] = mesh["Mesh"]["Vertices"][0] # Not correct, but just for now
del mesh["Mesh"]["vertex_indices"]
self.inputs[covetool_category].extend(meshes.values())
def has_triangulate_modifier(self, obj):
for modifier in obj.modifiers:
if modifier.type == 'TRIANGULATE':
if modifier.type == "TRIANGULATE":
return True
def get_covetool_category(self, obj):
if not hasattr(obj, 'data') or not isinstance(obj.data, bpy.types.Mesh):
if not hasattr(obj, "data") or not isinstance(obj.data, bpy.types.Mesh):
return
if 'IfcSlab' in obj.name:
return 'floors'
elif 'IfcRoof' in obj.name:
return 'roofs'
elif 'IfcWall' in obj.name:
if "IfcSlab" in obj.name:
return "floors"
elif "IfcRoof" in obj.name:
return "roofs"
elif "IfcWall" in obj.name:
if self.is_wall_internal(obj):
return 'interior_walls'
return 'walls'
elif 'IfcWindow' in obj.name:
return "interior_walls"
return "walls"
elif "IfcWindow" in obj.name:
if self.is_window_skylight(obj):
return 'skylights'
return 'windows'
elif 'IfcShadingDevice' in obj.name:
return 'shading_devices'
return "skylights"
return "windows"
elif "IfcShadingDevice" in obj.name:
return "shading_devices"
def is_wall_internal(self, obj):
pset_wallcommon = obj.BIMObjectProperties.psets.get('Pset_WallCommon')
pset_wallcommon = obj.BIMObjectProperties.psets.get("Pset_WallCommon")
if pset_wallcommon:
is_external = pset_wallcommon.properties.get('IsExternal')
is_external = pset_wallcommon.properties.get("IsExternal")
if is_external:
if is_external.string_value == 'True':
if is_external.string_value == "True":
return False
else:
return True
predefined_type = obj.BIMObjectProperties.attributes.get('PredefinedType')
if predefined_type and predefined_type.string_value in ['MOVABLE', 'PARTITIONING', 'PLUMBINGWALL']:
predefined_type = obj.BIMObjectProperties.attributes.get("PredefinedType")
if predefined_type and predefined_type.string_value in ["MOVABLE", "PARTITIONING", "PLUMBINGWALL"]:
return True
def is_window_skylight(self, obj):
predefined_type = obj.BIMObjectProperties.attributes.get('PredefinedType')
return predefined_type and predefined_type.string_value == 'SKYLIGHT'
predefined_type = obj.BIMObjectProperties.attributes.get("PredefinedType")
return predefined_type and predefined_type.string_value == "SKYLIGHT"
@@ -3,39 +3,39 @@ import bpy.types
class CoveToolProject(bpy.types.PropertyGroup):
name: bpy.props.StringProperty(name='Name')
run_set: bpy.props.StringProperty(name='Run Set')
url: bpy.props.StringProperty(name='URL')
name: bpy.props.StringProperty(name="Name")
run_set: bpy.props.StringProperty(name="Run Set")
url: bpy.props.StringProperty(name="URL")
class CoveToolSimpleAnalysis(bpy.types.PropertyGroup):
si_units: bpy.props.BoolProperty(name='SI Units')
building_height: bpy.props.StringProperty(name='Building Height')
roof_area: bpy.props.StringProperty(name='Roof Area')
floor_area: bpy.props.StringProperty(name='Floor Area')
skylight_area: bpy.props.StringProperty(name='Skylight Area')
wall_area_e: bpy.props.StringProperty(name='Wall Area E')
wall_area_ne: bpy.props.StringProperty(name='Wall Area NE')
wall_area_n: bpy.props.StringProperty(name='Wall Area N')
wall_area_nw: bpy.props.StringProperty(name='Wall Area NW')
wall_area_w: bpy.props.StringProperty(name='Wall Area W')
wall_area_sw: bpy.props.StringProperty(name='Wall Area SW')
wall_area_s: bpy.props.StringProperty(name='Wall Area S')
wall_area_se: bpy.props.StringProperty(name='Wall Area SE')
window_area_e: bpy.props.StringProperty(name='Window Area E')
window_area_ne: bpy.props.StringProperty(name='Window Area NE')
window_area_n: bpy.props.StringProperty(name='Window Area N')
window_area_nw: bpy.props.StringProperty(name='Window Area NW')
window_area_w: bpy.props.StringProperty(name='Window Area W')
window_area_sw: bpy.props.StringProperty(name='Window Area SW')
window_area_s: bpy.props.StringProperty(name='Window Area S')
window_area_se: bpy.props.StringProperty(name='Window Area SE')
si_units: bpy.props.BoolProperty(name="SI Units")
building_height: bpy.props.StringProperty(name="Building Height")
roof_area: bpy.props.StringProperty(name="Roof Area")
floor_area: bpy.props.StringProperty(name="Floor Area")
skylight_area: bpy.props.StringProperty(name="Skylight Area")
wall_area_e: bpy.props.StringProperty(name="Wall Area E")
wall_area_ne: bpy.props.StringProperty(name="Wall Area NE")
wall_area_n: bpy.props.StringProperty(name="Wall Area N")
wall_area_nw: bpy.props.StringProperty(name="Wall Area NW")
wall_area_w: bpy.props.StringProperty(name="Wall Area W")
wall_area_sw: bpy.props.StringProperty(name="Wall Area SW")
wall_area_s: bpy.props.StringProperty(name="Wall Area S")
wall_area_se: bpy.props.StringProperty(name="Wall Area SE")
window_area_e: bpy.props.StringProperty(name="Window Area E")
window_area_ne: bpy.props.StringProperty(name="Window Area NE")
window_area_n: bpy.props.StringProperty(name="Window Area N")
window_area_nw: bpy.props.StringProperty(name="Window Area NW")
window_area_w: bpy.props.StringProperty(name="Window Area W")
window_area_sw: bpy.props.StringProperty(name="Window Area SW")
window_area_s: bpy.props.StringProperty(name="Window Area S")
window_area_se: bpy.props.StringProperty(name="Window Area SE")
class CoveToolProperties(bpy.types.PropertyGroup):
username: bpy.props.StringProperty(name='Username')
password: bpy.props.StringProperty(name='Password')
token: bpy.props.StringProperty(name='Token')
projects: bpy.props.CollectionProperty(name='Projects', type=CoveToolProject)
active_project_index: bpy.props.IntProperty(name='Active Project Index')
username: bpy.props.StringProperty(name="Username")
password: bpy.props.StringProperty(name="Password")
token: bpy.props.StringProperty(name="Token")
projects: bpy.props.CollectionProperty(name="Projects", type=CoveToolProject)
active_project_index: bpy.props.IntProperty(name="Active Project Index")
simple_analysis: bpy.props.PointerProperty(type=CoveToolSimpleAnalysis)
@@ -1,11 +1,12 @@
import bpy.types
class BIM_PT_covetool(bpy.types.Panel):
bl_label = "cove.tool"
bl_idname = "BIM_PT_covetool"
bl_options = {'DEFAULT_CLOSED'}
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_options = {"DEFAULT_CLOSED"}
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "scene"
def draw(self, context):
@@ -17,36 +18,53 @@ class BIM_PT_covetool(bpy.types.Panel):
if not props.token:
row = layout.row()
row.prop(props, 'username')
row.prop(props, "username")
row = layout.row()
row.prop(props, 'password')
row.prop(props, "password")
row = layout.row()
row.operator('bim.covetool_login')
row.operator("bim.covetool_login")
return
layout.template_list('BIM_UL_covetool_projects', '', props, 'projects', props, 'active_project_index')
layout.template_list("BIM_UL_covetool_projects", "", props, "projects", props, "active_project_index")
row = layout.row()
row.operator('bim.covetool_run_analysis')
row.operator("bim.covetool_run_analysis")
prop_names = [ 'si_units', 'building_height', 'roof_area', 'floor_area',
'skylight_area', 'wall_area_e', 'wall_area_ne', 'wall_area_n',
'wall_area_nw', 'wall_area_w', 'wall_area_sw', 'wall_area_s',
'wall_area_se', 'window_area_e', 'window_area_ne', 'window_area_n',
'window_area_nw', 'window_area_w', 'window_area_sw',
'window_area_s', 'window_area_se']
prop_names = [
"si_units",
"building_height",
"roof_area",
"floor_area",
"skylight_area",
"wall_area_e",
"wall_area_ne",
"wall_area_n",
"wall_area_nw",
"wall_area_w",
"wall_area_sw",
"wall_area_s",
"wall_area_se",
"window_area_e",
"window_area_ne",
"window_area_n",
"window_area_nw",
"window_area_w",
"window_area_sw",
"window_area_s",
"window_area_se",
]
for prop_name in prop_names:
row = layout.row()
row.prop(props.simple_analysis, prop_name)
row = layout.row()
row.operator('bim.covetool_run_simple_analysis')
row.operator("bim.covetool_run_simple_analysis")
class BIM_UL_covetool_projects(bpy.types.UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
ob = data
if item:
layout.prop(item, 'name', text='', emboss=False)
layout.prop(item, "name", text="", emboss=False)
else:
layout.label(text='', translate=False)
layout.label(text="", translate=False)
@@ -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")