Tl;Dr:
I want to detect an orbit (could be pan or zoom) event from the Python API.
Longer:
If you want a bit more context, I am hiding some elements when I look through the camera. But when I move away (i.e., by orbiting), I would like these elements to be visible again.
def see_through_selected_camera():
# Look through camera
bpy.context.scene.camera = bpy.context.active_object
area = next(area for area in bpy.context.screen.areas if area.type == 'VIEW_3D')
area.spaces[0].region_3d.view_perspective = 'CAMERA'
# hide curves
objects = bpy.ops.object.select_by_type(type='CURVE')
objects = bpy.context.selected_objects
for obj in objects:
obj.hide_set(True)
# HERE I WANT TO DETECT A CHANGE IN THE ROTATION SUCH AS:
rot = area.spaces.active.region_3d.view_rotation
if detect_orbit_change():
for obj in objects:
obj.hide_set(False)
I cannot find a way to write detect_orbit_change() and detect such an event.
I was looking at msgBus but it seems like it is not triggered by changes made directly in the viewport.
It would not be ideal, but at that point, if I could just detect a mouse click I would be happy enough.
Thanks in advance, any help is appreciated!