mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-27 18:57:17 +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,14 +143,35 @@ 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
|
||||||
|
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))
|
||||||
|
|
||||||
|
for camera, camera_element in cameras:
|
||||||
|
self.camera, self.camera_element = camera, camera_element
|
||||||
self.file = IfcStore.get_file()
|
self.file = IfcStore.get_file()
|
||||||
|
|
||||||
with profile("Drawing generation process"):
|
with profile("Drawing generation process"):
|
||||||
@@ -168,7 +189,9 @@ class CreateDrawing(bpy.types.Operator):
|
|||||||
self.svg_writer.data_dir = context.scene.BIMProperties.data_dir
|
self.svg_writer.data_dir = context.scene.BIMProperties.data_dir
|
||||||
self.svg_writer.camera = self.camera
|
self.svg_writer.camera = self.camera
|
||||||
self.svg_writer.camera_width, self.svg_writer.camera_height = self.get_camera_dimensions()
|
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)))
|
self.svg_writer.camera_projection = tuple(
|
||||||
|
self.camera.matrix_world.to_quaternion() @ Vector((0, 0, -1))
|
||||||
|
)
|
||||||
|
|
||||||
with profile("Generate underlay"):
|
with profile("Generate underlay"):
|
||||||
underlay_svg = self.generate_underlay(context)
|
underlay_svg = self.generate_underlay(context)
|
||||||
|
|||||||
Reference in New Issue
Block a user