mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-21 14:23:53 +00:00
See #4481. Defer setting render visibility to drawing generation to speed up switching between drawings.
Doing obj.hide_render = True/False in a loop is slow and there is no bulk set command.
This commit is contained in:
@@ -341,6 +341,11 @@ class CreateDrawing(bpy.types.Operator):
|
|||||||
if not ifcopenshell.util.element.get_pset(self.drawing, "EPset_Drawing", "HasUnderlay"):
|
if not ifcopenshell.util.element.get_pset(self.drawing, "EPset_Drawing", "HasUnderlay"):
|
||||||
return
|
return
|
||||||
svg_path = self.get_svg_path(cache_type="underlay")
|
svg_path = self.get_svg_path(cache_type="underlay")
|
||||||
|
|
||||||
|
visible_object_names = {obj.name for obj in bpy.context.visible_objects}
|
||||||
|
for obj in bpy.context.view_layer.objects:
|
||||||
|
obj.hide_render = obj.name not in visible_object_names
|
||||||
|
|
||||||
context.scene.render.filepath = svg_path[0:-4] + ".png"
|
context.scene.render.filepath = svg_path[0:-4] + ".png"
|
||||||
drawing_style = context.scene.DocProperties.drawing_styles[self.cprops.active_drawing_style_index]
|
drawing_style = context.scene.DocProperties.drawing_styles[self.cprops.active_drawing_style_index]
|
||||||
|
|
||||||
|
|||||||
@@ -1716,20 +1716,6 @@ class Drawing(blenderbim.core.tool.Drawing):
|
|||||||
|
|
||||||
filtered_elements = cls.get_drawing_elements(drawing) | cls.get_drawing_spaces(drawing)
|
filtered_elements = cls.get_drawing_elements(drawing) | cls.get_drawing_spaces(drawing)
|
||||||
filtered_elements.add(drawing)
|
filtered_elements.add(drawing)
|
||||||
# Hide everything first, then selectively show. This is significantly faster.
|
|
||||||
with bpy.context.temp_override(area=next(a for a in bpy.context.screen.areas if a.type == "VIEW_3D")):
|
|
||||||
bpy.ops.object.hide_view_set(unselected=False)
|
|
||||||
bpy.ops.object.hide_view_set(unselected=True)
|
|
||||||
|
|
||||||
for view_layer_object in bpy.context.view_layer.objects:
|
|
||||||
element = tool.Ifc.get_entity(view_layer_object)
|
|
||||||
if not element or element.is_a("IfcTypeProduct"):
|
|
||||||
continue
|
|
||||||
if element in filtered_elements:
|
|
||||||
view_layer_object.hide_set(False)
|
|
||||||
view_layer_object.hide_render = False
|
|
||||||
elif view_layer_object.hide_render is not True:
|
|
||||||
view_layer_object.hide_render = True
|
|
||||||
|
|
||||||
subcontexts: list[ifcopenshell.entity_instance] = []
|
subcontexts: list[ifcopenshell.entity_instance] = []
|
||||||
target_view = cls.get_drawing_target_view(drawing)
|
target_view = cls.get_drawing_target_view(drawing)
|
||||||
@@ -1764,6 +1750,11 @@ class Drawing(blenderbim.core.tool.Drawing):
|
|||||||
if subcontext:
|
if subcontext:
|
||||||
subcontexts.append(context_filter)
|
subcontexts.append(context_filter)
|
||||||
|
|
||||||
|
# Hide everything first, then selectively show. This is significantly faster.
|
||||||
|
with bpy.context.temp_override(area=next(a for a in bpy.context.screen.areas if a.type == "VIEW_3D")):
|
||||||
|
bpy.ops.object.hide_view_set(unselected=False)
|
||||||
|
bpy.ops.object.hide_view_set(unselected=True)
|
||||||
|
|
||||||
# switch representations and hide elements without representations
|
# switch representations and hide elements without representations
|
||||||
for element in filtered_elements:
|
for element in filtered_elements:
|
||||||
obj = tool.Ifc.get_object(element)
|
obj = tool.Ifc.get_object(element)
|
||||||
@@ -1793,11 +1784,10 @@ class Drawing(blenderbim.core.tool.Drawing):
|
|||||||
has_context = True
|
has_context = True
|
||||||
break
|
break
|
||||||
|
|
||||||
# don't hide IfcAnnotations as some of them might exist without representations
|
# Don't hide IfcAnnotations as some of them might exist without representations
|
||||||
# e.g. with ObjectType = SYMBOL
|
if has_context or element.is_a("IfcAnnotation"):
|
||||||
if not has_context and not element.is_a("IfcAnnotation"):
|
# Note that render visibility is only set on drawing generation time for speed.
|
||||||
obj.hide_set(True)
|
obj.hide_set(False)
|
||||||
obj.hide_render = True
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_elements_in_camera_view(
|
def get_elements_in_camera_view(
|
||||||
|
|||||||
Reference in New Issue
Block a user