Skip to content
AlphaToolBox3D is in early alpha: features are incomplete and things can break. Use it at your own risk and keep copies of your files. Report a problem
ToolBox3D

Docs · Python API

tb.ops.viewport

14 operations. Without targets=, an operation works on the current selection, like its button in the editor.

Dolly View

tb.ops.viewport.dolly(*, factor: float) -> Result

Move the camera along its view direction: a factor above 1 moves away (2 doubles the distance), below 1 moves closer. Orthographic views zoom by the same factor.

  • Operation viewport.dolly
  • In Previewer, Model, Control Rig, Animation, Texture Paint
ArgumentTypeDefaultDescription
factorfloatrequiredDistance multiplier, greater than 0.

Exit Isolate

tb.ops.viewport.exit_isolate() -> Result

Leave Isolate Selected in this editor's viewport, like Alt+Q (a no-op when not isolating).

  • Operation viewport.exit_isolate
  • In Previewer, Model, Control Rig

Frame Viewport

tb.ops.viewport.frame(
    *,
    all: bool = False,
    nodes: Sequence[ObjectRef] = ...,
    padding: float = ...,
) -> Result

Frame the active viewport's selection (F), the named objects, or every visible object with all = true (A), keeping the view angle. padding scales the space around them (1.5 = the standard F padding). Requires a mounted 3D viewport; a successful call queues the scoped request rather than reporting camera completion.

  • Operation viewport.frame
  • In Previewer, Model, Control Rig, Animation, Texture Paint
ArgumentTypeDefaultDescription
allboolFalseFrame all visible objects instead of the current selection.
nodesSequence[ObjectRef]—Objects to frame by name or long name (groups frame their contents); default: the selection.
paddingfloat—Size multiplier around the framed bounds; default: the viewport's standard 1.5. (1…10).

Get Viewport Camera

tb.ops.viewport.get_camera() -> Result

The view camera as last drawn: position, target and up (metres), distance, whether it is orthographic (after queued changes) and its visible height, and the viewport's screen rect and center in points. viewport.set_camera takes the same pose back.

  • Operation viewport.get_camera
  • In Previewer, Model, Control Rig, Animation, Texture Paint

Isolate Selected

tb.ops.viewport.isolate(*, nodes: Sequence[ObjectRef] = ...) -> Result

Show only the given objects' meshes (default: the selection; groups isolate their meshes) in this editor's viewport, like Shift+I. View state: the document and history are unchanged; viewport.exit_isolate shows everything again.

  • Operation viewport.isolate
  • In Previewer, Model, Control Rig
ArgumentTypeDefaultDescription
nodesSequence[ObjectRef]—Objects to isolate by name or long name; default: the selection.

Orbit View

tb.ops.viewport.orbit(*, yaw: float = 0.0, pitch: float = 0.0) -> Result

Orbit the camera around its target: positive yaw turns the view left around the world up axis, positive pitch tilts it up. An orthographic view stays orthographic.

  • Operation viewport.orbit
  • In Previewer, Model, Control Rig, Animation, Texture Paint
ArgumentTypeDefaultDescription
yawfloat0.0Degrees around the world up axis.
pitchfloat0.0Degrees up (positive) or down.

Pan View

tb.ops.viewport.pan(*, dx: float = 0.0, dy: float = 0.0) -> Result

Pan the view as if the pan button dragged it by (dx, dy) screen points: the scene follows the drag.

  • Operation viewport.pan
  • In Previewer, Model, Control Rig, Animation, Texture Paint
ArgumentTypeDefaultDescription
dxfloat0.0Screen points to the right.
dyfloat0.0Screen points down.

Pick At

tb.ops.viewport.pick_at(*, x: float, y: float) -> Result

The nearest visible, unlocked object under screen point (x, y) of the caller's 3D viewport, in points like the rect viewport.get_camera reports: node, name, world point and normal, distance and triangle, or null on a miss. Uses what the viewport last drew and refuses while it is behind the document or when there is no 3D viewport (use scene.ray_cast there).

  • Operation viewport.pick_at
  • In Previewer, Model, Control Rig, Animation, Texture Paint
ArgumentTypeDefaultDescription
xfloatrequiredScreen x in points.
yfloatrequiredScreen y in points.

Preview Camera

tb.ops.viewport.preview_camera(
    *,
    mode: Literal["free", "face", "firstPerson"],
) -> Result

Preview the animation through a character camera: face (a perspective view that follows the head, orbit and dolly still work around it), firstPerson (the view from the character's eyes, turning with the head, as a game's first-person camera) or free (ordinary navigation). The character's head joint is found by name.

  • Operation viewport.preview_camera
  • In Animation
ArgumentTypeDefaultDescription
modeLiteral["free", "face", "firstPerson"]requiredfree, face or firstPerson. (free / face / firstPerson).

Reset View

tb.ops.viewport.reset_view() -> Result

Return to the default perspective view: (5, 5, 5) grid units looking at the origin.

  • Operation viewport.reset_view
  • In Previewer, Model, Control Rig, Animation, Texture Paint

Set Viewport Camera

tb.ops.viewport.set_camera(
    *,
    position: Vec3Like,
    target: Vec3Like,
    up: Vec3Like = ...,
    ortho_height: float = ...,
) -> Result

Put the view camera exactly at a pose viewport.get_camera reported: position and target in metres, optional up (default +Y) and, for an orthographic view, orthoHeight (the visible height in metres). Restores a saved view, e.g. between screenshots.

  • Operation viewport.set_camera
  • In Previewer, Model, Control Rig, Animation, Texture Paint
ArgumentTypeDefaultDescription
positionVec3LikerequiredEye position in metres.
targetVec3LikerequiredThe point the camera looks at and orbits around.
upVec3Like—Screen-up direction (default +Y).
ortho_heightfloat—Orthographic with this visible height in metres; omit for perspective.

Set Orthographic

tb.ops.viewport.set_ortho(*, ortho: bool) -> Result

Switch the view to orthographic (true) or perspective (false), keeping the pose and the apparent size at the target.

  • Operation viewport.set_ortho
  • In Previewer, Model, Control Rig, Animation, Texture Paint
ArgumentTypeDefaultDescription
orthoboolrequiredOrthographic when true.

Set View

tb.ops.viewport.set_view(
    *,
    view: Literal["persp", "top", "bottom", "front", "back", "right", "left"],
) -> Result

Look at the target from a named view at the current distance: persp is the default perspective direction, the axis views are orthographic.

  • Operation viewport.set_view
  • In Previewer, Model, Control Rig, Animation, Texture Paint
ArgumentTypeDefaultDescription
viewLiteral["persp", "top", "bottom", "front", "back", "right", "left"]requiredpersp, top, bottom, front, back, right or left. (persp / top / bottom / front / back / right / left).

Toggle Ortho View

tb.ops.viewport.toggle_ortho() -> Result

Switch between perspective and orthographic projection. Repeated calls alternate in order.

  • Operation viewport.toggle_ortho
  • In Previewer, Model, Control Rig, Animation, Texture Paint