Sub topic 9
Framing: View Selected, View All, and Local View
Framing moves the viewport so that the objects you care about fill the view. This chapter covers three commands: View Selected, View All, and Local View. It shows when to use each one, what each one changes, and how to script them.
It assumes you can already orbit, pan, and zoom, and that you know the standard views. It also assumes the default keymap and a numpad, or Emulate Numpad turned on.
Why framing matters
Orbit, pan, and zoom move the view by hand. Framing computes the move for you. It sets the view's center point and its distance from that point so the target fills the viewport. The orbit pivot is that center point, so after framing, orbiting turns around the thing you framed.
Framing changes the view's location and distance. It does not change the view's rotation. If you are looking at the scene from the front, you still look from the front afterward. Projection mode also stays as it was.
View Selected
View Selected frames the current selection.
- Shortcut: Numpad Period (
Numpad .). - Menu: View > Frame Selected.
The result depends on the mode you are in.
| Mode | What gets framed |
|---|---|
| Object Mode | The bounding box of all selected objects |
| Edit Mode | The selected vertices, edges, or faces |
| Pose Mode | The selected bones |
Edit Mode is where this command is most useful. If you select one face on a dense mesh and press Numpad ., the view moves to that face and the orbit pivot moves with it. You can then orbit around the face without it drifting off screen.
If nothing is selected, the command has nothing to frame and the view stays where it is. When View Selected seems to do nothing, check the selection first.
The operator also has a use_all_regions option. It matters in Quad View, which a later chapter covers. By default only the active viewport is framed.
View All
View All frames every visible object in the scene.
- Shortcut:
Home. - Menu: View > Frame All.
Use it as a reset when you have lost your bearings. After a bad pan or zoom, Home brings the whole scene back.
Some details can surprise you:
- Hidden objects are ignored. An object hidden with
H, or disabled in the viewport, does not count. - Lights and cameras count as objects. A far-away light stretches the framed area, and the rest of the scene ends up small. If View All leaves your model tiny, look for a distant light or camera.
- In camera view,
Homeframes the camera frame (the border of the render area). It does not frame the scene. Shift+Cdoes the same as View All and also resets the 3D cursor to the world origin. Use it only when you want both effects.
Local View
Local View isolates objects. It hides everything except the selection, then frames what remains.
- Shortcut:
Numpad /. Press it again to leave. - Menu: View > Local View > Toggle Local View.
This differs from hiding objects with H in two ways:
- Local View belongs to one viewport. Other 3D viewports keep showing the whole scene.
- It does not change object visibility flags. Nothing is hidden in the scene data. Leaving Local View restores the viewport exactly.
That makes it a good choice for detail work. You can isolate a single prop, model it without nearby geometry getting in the way, and leave. You can also run one viewport in Local View while another shows the whole scene, which is a convenient way to check a change in context.
While you are in Local View, View All frames only the local objects. The viewport header shows a "(Local)" note beside the object information, and the 3D viewport has a visual cue (the exact look depends on version). If your scene seems to have lost most of its objects, check whether you are in Local View before you suspect anything worse.
Local View also has a "Remove from Local View" command under View > Local View. It takes the selected objects out of the isolated set without leaving.
Local View in Edit Mode
Local View works on objects. In Edit Mode you can still toggle it, but it isolates the whole object you are editing, not part of the mesh. To hide part of a mesh, use the hide commands (H) instead.
Choosing among the three
A common sequence is Local View, then View Selected, then work, then leave Local View, then View All. Local View already frames on entry, so you often skip the second step.
Smooth View
Framing moves the view with a short animation. The setting is Smooth View in Preferences > Interface > Editing. The default is 200 ms. It only affects how the move looks. A value of 0 makes framing jump instantly. This is useful when you screen-record, or when you script several framing calls in a row.
Common errors
- Framing does nothing. Nothing is selected, or the Numpad Period key is not mapped because you have no numpad. Turn on Emulate Numpad in Preferences > Input, or use the View menu.
- View All shows a tiny scene. A far-away light, camera, or stray object is included. Select your real objects and use View Selected, or delete the stray.
- The objects vanished after framing. The view is likely farther than the clip end allows, or closer than clip start. The clipping chapter covers this.
- Most of the scene is missing. You are in Local View. Press
Numpad /to exit. - Framing a selection in perspective looks too close or too far. Perspective framing uses the lens settings. An orthographic view frames by scale instead. Switch projection if the result feels wrong.
Scripting framing
Framing operators are viewport operators, so they need a 3D viewport in their context. When you run a script from the Text Editor, the context points at the Text Editor, and calling these operators directly fails with a context error. The fix is temp_override, available in Blender 3.2 and later.
import bpy
for area in bpy.context.screen.areas:
if area.type == 'VIEW_3D':
region = next(r for r in area.regions if r.type == 'WINDOW')
with bpy.context.temp_override(area=area, region=region):
bpy.ops.view3d.view_all() # like Home
bpy.ops.view3d.view_selected() # like Numpad Period
breakThe loop finds the first 3D viewport and picks its main window region. The with block makes the operators run as if you had pressed the keys over that area. The first call frames everything, and the second then frames the selection. Because of Smooth View, you may see only the second move.
To toggle Local View from a script, call the operator inside the same kind of override:
import bpy
for area in bpy.context.screen.areas:
if area.type == 'VIEW_3D':
region = next(r for r in area.regions if r.type == 'WINDOW')
with bpy.context.temp_override(area=area, region=region):
bpy.ops.view3d.localview(frame_selected=True)
breakRunning this once enters Local View on the selected objects. Running it again leaves. The frame_selected option controls whether the view frames the isolated objects on entry. The default is True.
If you want to read the result, the view's center and distance live on the region data:
import bpy
for area in bpy.context.screen.areas:
if area.type == 'VIEW_3D':
r3d = area.spaces.active.region_3d
print(r3d.view_location) # the orbit pivot
print(r3d.view_distance) # distance from the view to the pivot
breakAfter framing, view_location shows the new pivot. The Smooth View animation may still be running when your script reads the value, so the numbers can lag behind the final view.
Summary table
| Command | Shortcut | Scope | Changes scene data |
|---|---|---|---|
| View Selected | `Numpad .` | Selection in the active viewport | No |
| View All | `Home` | All visible objects | No |
| Local View | `Numpad /` | Selected objects, one viewport | No |
Exercise
You press Home and your finished model appears very small in the corner of the viewport, with a lot of empty space around it. Name the most likely cause and two ways to get a good view of the model.
Show answer
View All includes every visible object, and a far-away light, camera, or stray object stretches the framed area. To fix it, select the model and press Numpad Period (View Selected), or select the model and press Numpad Slash to enter Local View, which isolates the model and frames it. Deleting or hiding the stray object, then pressing Home, also works.
Exercise
You are in Local View on a chair. In another viewport, the whole room is still visible. A colleague says the other objects must be hidden in the scene. Is that right, and how do you leave Local View?
Show answer
No. Local View is a per-viewport display state and does not change object visibility in the scene data. Other viewports and the render still show every object. You leave it by pressing Numpad Slash again, or by choosing View > Local View > Toggle Local View.
Exercise
Why does calling bpy.ops.view3d.view_selected() from a script in the Text Editor fail, and what is the fix?
Show answer
The operator needs a 3D viewport area and its main window region in the context, and the Text Editor context has neither. Wrap the call in with bpy.context.temp_override(area=area, region=region): using a VIEW_3D area and its WINDOW region (Blender 3.2 or later).