mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
See #7133. Sync viewport visibility with render visibility when generating underlays.
This commit is contained in:
@@ -443,6 +443,8 @@ class CreateDrawing(bpy.types.Operator):
|
||||
context.scene.render.filepath = str(Path(svg_path).with_suffix(".png"))
|
||||
assert (drawing_style := self.cprops.get_active_drawing_style())
|
||||
|
||||
tool.Blender.sync_render_visibility()
|
||||
|
||||
if drawing_style.render_type == "DEFAULT":
|
||||
bpy.ops.render.render(write_still=True)
|
||||
else:
|
||||
|
||||
@@ -1889,6 +1889,24 @@ class Blender(bonsai.core.tool.Blender):
|
||||
obj.select_set(True)
|
||||
bpy.context.view_layer.objects.active = previously_active
|
||||
|
||||
@classmethod
|
||||
def sync_render_visibility(cls):
|
||||
# Doing bpy.ops.object.hide_render_clear_all() or
|
||||
# bpy.ops.object.isolate_type_render() is extremely slow.
|
||||
# Hopefully this doesn't crash on Windows, it doesn't crash on Linux.
|
||||
should_hides = [0 if obj.visible_get() else 1 for obj in bpy.data.objects]
|
||||
should_hides = np.fromiter(should_hides, dtype=np.uint8, count=len(should_hides))
|
||||
bpy.data.objects.foreach_set("hide_render", should_hides)
|
||||
return # Otherwise...
|
||||
# for obj in bpy.data.objects:
|
||||
# if not obj.data:
|
||||
# continue
|
||||
# # For speed, check equality prior to change to prevent needless updates
|
||||
# if (is_visible := obj.visible_get()) and obj.hide_render is True:
|
||||
# obj.hide_render = False
|
||||
# elif not is_visible and obj.hide_render is False:
|
||||
# obj.hide_render = True
|
||||
|
||||
@classmethod
|
||||
def hide_objects(cls, objs):
|
||||
previously_selected = {o.name for o in bpy.context.selected_objects}
|
||||
|
||||
Reference in New Issue
Block a user