Skip to content

.NET API

ViewApi

Rhino VIEWPORT control for batch rendering: point the camera, restore named views, switch display modes and capture the frame to a file. (The Realtime Render viewer has its own camera — see RealtimeRenderApi. This facade drives the Rhino viewports themselves.) None of this modifies the document’s geometry; camera moves are license-free, capturing a file is gated like the other exports.

from ArtisanPlugin.Scripting import ViewApi

See also the guide, Views › Capture, and the Python package, ra.view.

Methods

Method
CaptureCaptures viewport (null = the active one) to a PNG at the given pixel size (0 = the viewport’s current size).
DescribeThe open viewports, the saved named views and the available display modes — the vocabularies the other methods accept.
ImportNamedViewsImports the named views saved in another 3dm file into the active document — the way to give every document of a batch run the same standard camera angles: keep them once in a template 3dm, import, then RestoreNamedView + Capture per angle.
RestoreNamedViewRestores a saved named view onto viewport (null = the active one).
SaveNamedViewSaves (or overwrites) the current camera of viewport as a named view — the building block for reusable batch-render angles.
SetCameraPlaces the camera of viewport (null = the active one) at location looking at target, in perspective projection.
SetDisplayModeSwitches the display mode of viewport (null = the active one).
ZoomExtentsZooms viewport (null = the active one) to the extents of the visible geometry.

Capture

string ViewApi.Capture(string path, int width = 0, int height = 0, string viewport = null)

Captures viewport (null = the active one) to a PNG at the given pixel size (0 = the viewport’s current size). Returns the full path written (“.png” appended when missing; folders are created).

ParameterTypeDefault
pathstringrequired
widthint0
heightint0
viewportstringnull

Returns string.

Describe

string ViewApi.Describe()

The open viewports, the saved named views and the available display modes — the vocabularies the other methods accept.

Returns string.

ImportNamedViews

IReadOnlyList<string> ViewApi.ImportNamedViews(string path)

Imports the named views saved in another 3dm file into the active document — the way to give every document of a batch run the same standard camera angles: keep them once in a template 3dm, import, then RestoreNamedView + Capture per angle. A view whose name already exists in the document is skipped (the document’s own view wins). Returns the names imported.

ParameterTypeDefault
pathstringrequired

Returns IReadOnlyList<string>.

RestoreNamedView

void ViewApi.RestoreNamedView(string name, string viewport = null)

Restores a saved named view onto viewport (null = the active one). The names come from Describe().

ParameterTypeDefault
namestringrequired
viewportstringnull

SaveNamedView

void ViewApi.SaveNamedView(string name, string viewport = null)

Saves (or overwrites) the current camera of viewport as a named view — the building block for reusable batch-render angles.

ParameterTypeDefault
namestringrequired
viewportstringnull

SetCamera

void ViewApi.SetCamera(
    Point3d location,
    Point3d target,
    double lensMm = 0,
    string viewport = null)

Places the camera of viewport (null = the active one) at location looking at target, in perspective projection. lensMm > 0 also sets the 35mm-equivalent lens length (50 is a natural product shot, 85-100 flattens like a macro lens).

ParameterTypeDefault
locationPoint3drequired
targetPoint3drequired
lensMmdouble0
viewportstringnull

SetDisplayMode

void ViewApi.SetDisplayMode(string mode, string viewport = null)

Switches the display mode of viewport (null = the active one). Mode names come from Describe() — e.g. Wireframe, Shaded, Rendered, Raytraced, Arctic, Pen.

ParameterTypeDefault
modestringrequired
viewportstringnull

ZoomExtents

void ViewApi.ZoomExtents(string viewport = null)

Zooms viewport (null = the active one) to the extents of the visible geometry.

ParameterTypeDefault
viewportstringnull