Skip to content

Scripting API

Camera

from ArtisanPlugin.Scripting import RealtimeRenderApi as rtr

Three ways to place the viewer’s camera - none of them touches Rhino’s viewports. All three fire and forget: they queue the move into the page and return immediately.

Camera presets

rtr.SetViewerCameraPreset("three-quarter")     # -> None

Moves the viewer camera to a named preset and frames the model automatically. Valid ids, exactly as the viewer ships them:

front, back, left, right, top, bottom, three-quarter, three-quarter-left, detail, dramatic-low.

The name you pass is trimmed, lower-cased and has underscores turned into hyphens, so "Three_Quarter" and "three-quarter" are the same preset. Anything else throws “Unknown camera preset ‘<name>’. Valid: front, back, left, right, top, bottom, three-quarter, three-quarter-left, detail, dramatic-low.” - and that validation happens before the window is touched, so a typo fails the same way whether or not the viewer is open.

Explicit camera

from Rhino.Geometry import Point3d
rtr.SetViewerCamera(Point3d(40, -60, 30), Point3d(0, 0, 5))   # -> None
ParameterDefaultMeaning
positionrequiredCamera eye point, Point3d
targetrequiredPoint the camera looks at, Point3d

Both points are in viewer/GLB coordinates, which are the same coordinates as the Rhino model, in millimetres. There is no field-of-view or roll argument: the viewer keeps its own lens settings.

Unlike the presets, this does not reframe - the view is exactly what those two points give you, so a target far from the geometry leaves the piece off-screen.

Zoom extents

rtr.ViewerZoomExtents()            # -> None

Frames the whole model in the viewer, keeping the current direction. Useful after an UpdateRender that changed the size of the piece, or after a SetViewerCamera that overshot.

Turntables

The camera also spins on its own: set autoRotate through Scene & effects and the viewer orbits the piece continuously - which, combined with Video, is the whole recipe for a turntable clip.