📋 Metadata

💬 Content

I wrote this a while back to make a single hotkey frame selected objects if selected, or all objects if none are selected. It works, but doesn’t use smooth view in preferences, it just pops immediately.

When I use bpy.ops.view3d.view_selected(use_all_regions=False) from the View menu in 3dview, there are a bunch of bpy.ops.view3d.smoothview() print outs.

Is bpy.ops.view3d.smoothview() something I need to include in the script as well?

if bpy.context.object.mode == 'OBJECT':
	selected = list(bpy.context.selected_objects)
	if len(selected) != 0:
		bpy.ops.view3d.view_selected(use_all_regions=False)

	elif len(selected) == 0:
		bpy.ops.view3d.view_all(center=False)

🔗 View on Blender Artists