Scripting API
Set camera
from ArtisanPlugin.Scripting import ViewApi as view
SetCamera points a Rhino viewport where you want it: camera at location, looking at target, in perspective projection. It is the primitive behind every scripted product shot - when you need a repeatable three-quarter angle on a ring rather than whatever the user last left on screen, you set the two points yourself and capture.
Usage
view.SetCamera(location, target, lensMm = 0, viewport = None)
| Parameter | Default | Meaning |
|---|---|---|
location | - | Camera position, a Point3d in document units (mm) |
target | - | The point the camera looks at, a Point3d in mm |
lensMm | 0 -> keep the viewport’s current lens | 35mm-equivalent focal length. 50 is a natural product shot; 85-100 flattens the piece like a macro lens |
viewport | None | Name of the viewport to drive; None means the active one |
Per the house convention, 0 for lensMm means “leave the lens alone”, not “zero millimetres” - the call reuses the viewport’s existing Camera35mmLensLength.
The call always switches the viewport to perspective projection, whether or not you pass a lens. Aiming a parallel view such as Top or Front with SetCamera therefore converts it to a perspective view, and it stays that way until something restores it - a named view, or the user. If you want the standard parallel views left intact, drive a dedicated viewport instead, or restore a named view rather than setting the camera by hand.
Returns void. It changes the view only: the camera, its target and its projection. No object is created, moved or deleted, the document is not marked modified, and it needs no Transaction - camera moves are not undoable document edits. No licence check either; this is one of the free methods on the facade. The views are redrawn once at the end.
Which viewport does None hit?
Leave viewport at None - or pass an empty or whitespace-only string, which is treated the same - and the call resolves to Rhino’s active view, the one Describe() marks with " (active)". If there is no document open it throws InvalidOperationException with "No active document.", and if a document is open but no view is active, InvalidOperationException with "No active view.".
Pass a name and it is matched against the standard model viewports, case-insensitively and with surrounding whitespace trimmed, so "top", "Top" and " Top " all find Top. Layout (page) viewports are not in the list and cannot be addressed. A name that matches nothing throws ArgumentException, and the message lists what was available:
Unknown viewport 'Persp'. Viewports: Perspective, Top, Front, Right.
That resolution rule is identical for every method on this facade.