Scripting API
Zoom extents
from ArtisanPlugin.Scripting import ViewApi as view
ZoomExtents pulls the camera back until everything visible fits in the viewport - the scripted equivalent of Rhino’s Zoom Extents. In a batch run it is the honest way to frame a document whose contents you do not know in advance: you cannot pick sensible camera distances for an unseen ring, but you can restore an angle, zoom to extents and capture.
Usage
view.ZoomExtents(viewport = None)
| Parameter | Default | Meaning |
|---|---|---|
viewport | None | Viewport to zoom; None means the active one |
It frames the visible geometry only: objects on hidden layers, hidden objects and anything the current display mode does not draw are excluded, so turning layers off before zooming is a legitimate way to frame a subset. The camera direction and the lens are untouched - only the distance and the frustum change - so calling it after SetCamera or RestoreNamedView keeps your angle and just fixes the framing.
Returns void. It changes the view only: nothing is added to or altered in the document, the file is not marked modified, no Transaction is needed and no licence is checked. The views are redrawn once at the end.
Which viewport does None hit?
The same rule as everywhere on this facade. None, or an empty or whitespace-only string, resolves to Rhino’s active view - the one Describe() tags with " (active)". A name is matched against the standard model viewports, case-insensitively and trimmed; layout (page) viewports are not in the list and cannot be addressed. An unknown name throws ArgumentException listing the real ones:
Unknown viewport 'Perspective 2'. Viewports: Perspective, Top, Front, Right.
With no document open it throws InvalidOperationException with "No active document.", and with a document but nothing active, InvalidOperationException with "No active view."