mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-17 14:02:27 +00:00
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
This commit is contained in:
@@ -199,6 +199,11 @@ class CreateDrawing(bpy.types.Operator):
|
|||||||
+ "SHIFT+CLICK to print all selected drawings"
|
+ "SHIFT+CLICK to print all selected drawings"
|
||||||
)
|
)
|
||||||
print_all: bpy.props.BoolProperty(name="Print All", default=False, options={"SKIP_SAVE"})
|
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
|
@classmethod
|
||||||
def poll(cls, context):
|
def poll(cls, context):
|
||||||
@@ -220,7 +225,8 @@ class CreateDrawing(bpy.types.Operator):
|
|||||||
else:
|
else:
|
||||||
drawings_to_print = [self.props.active_drawing_id]
|
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:
|
if self.print_all:
|
||||||
bpy.ops.bim.activate_drawing(drawing=drawing_id, camera_view_point=False)
|
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:
|
if os.path.isfile(svg_path) and self.props.should_use_linework_cache:
|
||||||
return svg_path
|
return svg_path
|
||||||
|
|
||||||
with profile("sync"):
|
# in case of printing multiple drawings we need to sync just once
|
||||||
# All very hackish whilst prototyping
|
if self.sync and self.drawing_index == 0:
|
||||||
exporter = blenderbim.bim.export_ifc.IfcExporter(None)
|
with profile("sync"):
|
||||||
exporter.file = tool.Ifc.get()
|
# All very hackish whilst prototyping
|
||||||
invalidated_elements = exporter.sync_all_objects()
|
exporter = blenderbim.bim.export_ifc.IfcExporter(None)
|
||||||
invalidated_elements += exporter.sync_edited_objects()
|
exporter.file = tool.Ifc.get()
|
||||||
invalidated_guids = [e.GlobalId for e in invalidated_elements if hasattr(e, "GlobalId")]
|
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
|
# If we have already calculated it in the SVG in the past, don't recalculate
|
||||||
edited_guids = set()
|
edited_guids = set()
|
||||||
@@ -525,8 +535,6 @@ class CreateDrawing(bpy.types.Operator):
|
|||||||
drawing_elements = tool.Drawing.get_drawing_elements(self.camera_element)
|
drawing_elements = tool.Drawing.get_drawing_elements(self.camera_element)
|
||||||
|
|
||||||
self.setup_serialiser(ifc, target_view)
|
self.setup_serialiser(ifc, target_view)
|
||||||
cache = IfcStore.get_cache()
|
|
||||||
[cache.remove(guid) for guid in invalidated_guids]
|
|
||||||
tree = ifcopenshell.geom.tree()
|
tree = ifcopenshell.geom.tree()
|
||||||
tree.enable_face_styles(True)
|
tree.enable_face_styles(True)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user