mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-24 20:00:02 +00:00
Option to print all svg drawings #2794
It's working either if you shift click the printing button or supply `print_all = True` argument to `bim.create_drawing operator`.
This commit is contained in:
@@ -143,46 +143,69 @@ class CreateDrawing(bpy.types.Operator):
|
|||||||
|
|
||||||
bl_idname = "bim.create_drawing"
|
bl_idname = "bim.create_drawing"
|
||||||
bl_label = "Create Drawing"
|
bl_label = "Create Drawing"
|
||||||
|
bl_description = (
|
||||||
|
"Creates/refreshes a .svg drawing based on currently active camera.\n\n"
|
||||||
|
+ "SHIFT+CLICK to print all annotations"
|
||||||
|
)
|
||||||
|
print_all: bpy.props.BoolProperty(name="Print all", default=False)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
return bool(tool.Ifc.get() and tool.Drawing.is_camera_orthographic() and tool.Drawing.is_drawing_active())
|
return bool(tool.Ifc.get() and tool.Drawing.is_camera_orthographic() and tool.Drawing.is_drawing_active())
|
||||||
|
|
||||||
|
def invoke(self, context, event):
|
||||||
|
# printing all annotations on shift+click
|
||||||
|
if event.type == "LEFTMOUSE" and event.shift:
|
||||||
|
self.print_all = True
|
||||||
|
return self.execute(context)
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
self.camera = context.scene.camera
|
if not self.print_all:
|
||||||
self.camera_element = tool.Ifc.get_entity(self.camera)
|
camera = context.scene.camera
|
||||||
self.file = IfcStore.get_file()
|
cameras = [(camera, tool.Ifc.get_entity(camera))]
|
||||||
|
else:
|
||||||
|
cameras = []
|
||||||
|
for drawing_prop in bpy.context.scene.DocProperties.drawings:
|
||||||
|
camera_element = tool.Ifc.get().by_id(drawing_prop.ifc_definition_id)
|
||||||
|
camera = tool.Ifc.get_object(camera_element)
|
||||||
|
cameras.append((camera, camera_element))
|
||||||
|
|
||||||
with profile("Drawing generation process"):
|
for camera, camera_element in cameras:
|
||||||
with profile("Initialize drawing generation process"):
|
self.camera, self.camera_element = camera, camera_element
|
||||||
self.props = context.scene.DocProperties
|
self.file = IfcStore.get_file()
|
||||||
self.cprops = self.camera.data.BIMCameraProperties
|
|
||||||
self.drawing_name = self.file.by_id(self.camera.BIMObjectProperties.ifc_definition_id).Name
|
|
||||||
self.get_scale()
|
|
||||||
if self.cprops.update_representation(self.camera):
|
|
||||||
bpy.ops.bim.update_representation(obj=self.camera.name, ifc_representation_class="")
|
|
||||||
|
|
||||||
self.svg_writer = svgwriter.SvgWriter()
|
with profile("Drawing generation process"):
|
||||||
self.svg_writer.human_scale = self.human_scale
|
with profile("Initialize drawing generation process"):
|
||||||
self.svg_writer.scale = self.scale
|
self.props = context.scene.DocProperties
|
||||||
self.svg_writer.data_dir = context.scene.BIMProperties.data_dir
|
self.cprops = self.camera.data.BIMCameraProperties
|
||||||
self.svg_writer.camera = self.camera
|
self.drawing_name = self.file.by_id(self.camera.BIMObjectProperties.ifc_definition_id).Name
|
||||||
self.svg_writer.camera_width, self.svg_writer.camera_height = self.get_camera_dimensions()
|
self.get_scale()
|
||||||
self.svg_writer.camera_projection = tuple(self.camera.matrix_world.to_quaternion() @ Vector((0, 0, -1)))
|
if self.cprops.update_representation(self.camera):
|
||||||
|
bpy.ops.bim.update_representation(obj=self.camera.name, ifc_representation_class="")
|
||||||
|
|
||||||
with profile("Generate underlay"):
|
self.svg_writer = svgwriter.SvgWriter()
|
||||||
underlay_svg = self.generate_underlay(context)
|
self.svg_writer.human_scale = self.human_scale
|
||||||
|
self.svg_writer.scale = self.scale
|
||||||
|
self.svg_writer.data_dir = context.scene.BIMProperties.data_dir
|
||||||
|
self.svg_writer.camera = self.camera
|
||||||
|
self.svg_writer.camera_width, self.svg_writer.camera_height = self.get_camera_dimensions()
|
||||||
|
self.svg_writer.camera_projection = tuple(
|
||||||
|
self.camera.matrix_world.to_quaternion() @ Vector((0, 0, -1))
|
||||||
|
)
|
||||||
|
|
||||||
with profile("Generate linework"):
|
with profile("Generate underlay"):
|
||||||
linework_svg = self.generate_linework(context)
|
underlay_svg = self.generate_underlay(context)
|
||||||
|
|
||||||
with profile("Generate annotation"):
|
with profile("Generate linework"):
|
||||||
annotation_svg = self.generate_annotation(context)
|
linework_svg = self.generate_linework(context)
|
||||||
|
|
||||||
with profile("Combine SVG layers"):
|
with profile("Generate annotation"):
|
||||||
svg_path = self.combine_svgs(context, underlay_svg, linework_svg, annotation_svg)
|
annotation_svg = self.generate_annotation(context)
|
||||||
|
|
||||||
open_with_user_command(context.preferences.addons["blenderbim"].preferences.svg_command, svg_path)
|
with profile("Combine SVG layers"):
|
||||||
|
svg_path = self.combine_svgs(context, underlay_svg, linework_svg, annotation_svg)
|
||||||
|
|
||||||
|
open_with_user_command(context.preferences.addons["blenderbim"].preferences.svg_command, svg_path)
|
||||||
|
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user