Adding drawings now creates groups and psets. Also very basic operator added to call IfcConvert from UI. See #1153.

This commit is contained in:
Dion Moult
2021-03-10 17:47:36 +11:00
parent 1a7ea1ea05
commit 4afcca8550
8 changed files with 253 additions and 158 deletions
@@ -1,6 +1,14 @@
import os
import bpy
import json
import subprocess
import webbrowser
from blenderbim.bim.operator import open_with_user_command
from blenderbim.bim.ifc import IfcStore
from blenderbim.bim.module.group.data import Data as GroupData
from blenderbim.bim.module.pset.data import Data as PsetData
cwd = os.path.dirname(os.path.realpath(__file__))
class AddDrawing(bpy.types.Operator):
bl_idname = "bim.add_drawing"
@@ -28,6 +36,54 @@ class AddDrawing(bpy.types.Operator):
area = next(area for area in context.screen.areas if area.type == "VIEW_3D")
area.spaces[0].region_3d.view_perspective = "CAMERA"
new.camera = camera
bpy.ops.bim.assign_class(obj=camera.name, ifc_class="IfcAnnotation")
bpy.ops.bim.assign_class(obj=camera.name, ifc_class="IfcAnnotation", predefined_type="DRAWING")
bpy.ops.bim.activate_drawing_style()
bpy.ops.bim.add_group()
bpy.ops.bim.assign_group(product=camera.name, group=sorted(GroupData.groups.keys())[-1])
bpy.ops.bim.add_pset(obj=camera.name, obj_type="Object", pset_name="EPset_Drawing")
pset_id = sorted(PsetData.products[camera.BIMObjectProperties.ifc_definition_id]["psets"])[-1]
bpy.ops.bim.edit_pset(
obj=camera.name,
obj_type="Object",
pset_id=pset_id,
properties=json.dumps({"TargetView": "PLAN_VIEW", "Scale": "1/100"}),
)
return {"FINISHED"}
class CreateDrawing(bpy.types.Operator):
bl_idname = "bim.create_drawing"
bl_label = "Create Drawing"
def execute(self, context):
ifcconvert_path = os.path.join(cwd, "..", "..", "..", "libs", "IfcConvert")
subprocess.run(
[
ifcconvert_path,
context.scene.BIMProperties.ifc_file,
"-yv",
context.scene.BIMProperties.ifc_file[0:-4] + ".svg",
"--plan",
"--model",
"--section-height-from-storeys",
"--section-height=1.2",
"--door-arcs",
"--print-space-names",
"--print-space-areas",
"--bounds=1024x1024",
"--elevation-ref=DRAWING",
"--svg-xmlns",
"--svg-project",
"--svg-poly",
"--exclude",
"entities",
"IfcSpace",
"IfcOpeningElement",
]
)
open_with_user_command(
bpy.context.preferences.addons["blenderbim"].preferences.svg_command,
context.scene.BIMProperties.ifc_file[0:-4] + ".svg",
)
return {"FINISHED"}