I’m looking into creating a script that automatically frames all nodes when you switch to either the Shader or Compositor workspaces
I understand that within a script, the command bpy.ops.node.view_all() should be called using context (which I haven’t figured out yet).
At the moment, I’ve been able to get the script to monitor what workspace the user is in:
import bpy
def rna_callback():
print (bpy.context.workspace)
def subscribe():
handle = object()
bpy.msgbus.subscribe_rna(
key=(bpy.types.Window, "workspace"),
owner=handle,
args=(), # Callback args
notify=rna_callback)
return handle
def unsubscribe(handle):
bpy.msgbus.clear_by_owner(handle)
if __name__ == "__main__":
bpy._handle = subscribe()
I’m trying to understand how I can call bpy.ops.node.view_all() within this script (the next step would be putting it in a IF statement to only call it when the user enters the Shader or Compositor workspace).
I know that the function is only a keypress away so my idea seems a bit lazy, but I’m trying to change some repetitive tasks to something Blender could do automatically.
Of course, if there’s an addon that automatically does this task, I would WAY more choose that than scripting this.
Thanks for any help you could provide!