Navigation papercut: "Home" and "Frame Selected" behaviors when nothing is Selected

This is a little thing, but a ‘papercut’ or ‘speed bump’:

OBJ MODE: When there is NOTHING in the Scene, it’d be nice if HOME centered the world origin in the 3dView. (Or, optionally, centered the 3dC, but it should do something.)

EDIT MODE: when nothing (no element of an Object) is SELECTED, it’d be nice if “Frame Selected” essentially functioned as a “Frame Current Object”. You could this as “Frame All Parts Of Current Object” if you like.

My beef here that in the cases listed, hitting those respective keys does NOTHING. I don’t think that’s very smart. They should do SOMETHING.

1 Like

Yes the framing behaviors should be contextually aware if nothing is selected. This annoyed me so much that I started writing an operator to tackle it but then got distracted by some other scripts I was writing.

This is incomplete but I did get some partial functionality working before I got distracted. In object mode and edit mesh mode if something is selected it frames Selected, or if nothing is selected it frames All. In some other modes (like curve edit) the frame Selected part should still function (like frame the selected bezier curve control handles) but the contextual frame All won’t work and you’ll have to frame All manually.

You would replace the Frame Selected operator in your keymap (3D View > 3D View (Global)) with this. It probably wouldn’t be too hard to modify but really this functionality should come with Blender right out of the box.

class KO_Frame_Objects(bpy.types.Operator):
    bl_idname = "ko.frame_objects"
    bl_label = "KO Frame Objects"
    bl_description="Contextually frame selected or frame all"

    def poll(cls, context):
        return context.scene is not None

    def execute(self, context):
        #If nothing is selected, frame all.
        if len(context.selected_objects) == 0:
            bpy.ops.view3d.view_all('INVOKE_DEFAULT', center=False)
            return {'FINISHED'}
        elif len(context.selected_objects) >= 1:
            mode_string = context.mode
            objects = context.selected_objects
            # print(objects)
            selected_components = 0
            if mode_string == 'EDIT_MESH':
                for obj in objects:
                    # print(obj)
                    vertcount =[0]
                    edgecount =[1]
                    facecount =[2]
                    selected_components += (selected_components + vertcount + edgecount + facecount)
                    # print("selected_components is ", selected_components)
                if selected_components == 0:
                    bpy.ops.view3d.view_all('INVOKE_DEFAULT', center=False)
                elif selected_components > 0:
                    bpy.ops.view3d.view_selected('INVOKE_DEFAULT', use_all_regions=False)
                bpy.ops.view3d.view_selected('INVOKE_DEFAULT', use_all_regions=False)
        return {'FINISHED'}