From d0e1a04fba4fec5def9a2c8766b6cf552246a6b3 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Thu, 4 Apr 2024 16:07:19 +0500 Subject: [PATCH] bim.create_drawing to sync only once if printing multiple drawings Turned out syncing process takes too much time on large projects, so we can speed up the printing process by syncing just once. Also exposed option not to sync to operator's properties to allow debugging failing elements. A bit related to #4500 --- .../blenderbim/bim/module/drawing/operator.py | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/drawing/operator.py b/src/blenderbim/blenderbim/bim/module/drawing/operator.py index 38125e0414..9b575796dc 100644 --- a/src/blenderbim/blenderbim/bim/module/drawing/operator.py +++ b/src/blenderbim/blenderbim/bim/module/drawing/operator.py @@ -199,6 +199,11 @@ class CreateDrawing(bpy.types.Operator): + "SHIFT+CLICK to print all selected drawings" ) print_all: bpy.props.BoolProperty(name="Print All", default=False, options={"SKIP_SAVE"}) + sync: bpy.props.BoolProperty( + name="Sync Before Creating Drawing", + description="Could save some time if you're sure IFC and current Blender session are already in sync", + default=True, + ) @classmethod def poll(cls, context): @@ -220,7 +225,8 @@ class CreateDrawing(bpy.types.Operator): else: drawings_to_print = [self.props.active_drawing_id] - for drawing_id in drawings_to_print: + for drawing_i, drawing_id in enumerate(drawings_to_print): + self.drawing_index = drawing_i if self.print_all: bpy.ops.bim.activate_drawing(drawing=drawing_id, camera_view_point=False) @@ -485,13 +491,17 @@ class CreateDrawing(bpy.types.Operator): if os.path.isfile(svg_path) and self.props.should_use_linework_cache: return svg_path - with profile("sync"): - # All very hackish whilst prototyping - exporter = blenderbim.bim.export_ifc.IfcExporter(None) - exporter.file = tool.Ifc.get() - invalidated_elements = exporter.sync_all_objects() - invalidated_elements += exporter.sync_edited_objects() - invalidated_guids = [e.GlobalId for e in invalidated_elements if hasattr(e, "GlobalId")] + # in case of printing multiple drawings we need to sync just once + if self.sync and self.drawing_index == 0: + with profile("sync"): + # All very hackish whilst prototyping + exporter = blenderbim.bim.export_ifc.IfcExporter(None) + exporter.file = tool.Ifc.get() + invalidated_elements = exporter.sync_all_objects() + invalidated_elements += exporter.sync_edited_objects() + invalidated_guids = [e.GlobalId for e in invalidated_elements if hasattr(e, "GlobalId")] + cache = IfcStore.get_cache() + [cache.remove(guid) for guid in invalidated_guids] # If we have already calculated it in the SVG in the past, don't recalculate edited_guids = set() @@ -525,8 +535,6 @@ class CreateDrawing(bpy.types.Operator): drawing_elements = tool.Drawing.get_drawing_elements(self.camera_element) self.setup_serialiser(ifc, target_view) - cache = IfcStore.get_cache() - [cache.remove(guid) for guid in invalidated_guids] tree = ifcopenshell.geom.tree() tree.enable_face_styles(True)