Skip to content

Python package

ra.view

Viewport cameras, display modes, named views and captures.

import rhinoartisan as ra

Wraps ArtisanPlugin.Scripting.ViewApi.

Functions

Function
capture()Captures viewport (None = the active one) to a PNG at the given pixel size (0 = the viewport’s current size).
describe()The open viewports, the saved named views and the available display modes — the vocabularies the other methods accept.
import_named_views()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.
restore_named_view()Restores a saved named view onto viewport (None = the active one).
save_named_view()Saves (or overwrites) the current camera of viewport as a named view — the building block for reusable batch-render angles.
set_camera()Places the camera of viewport (None = the active one) at location looking at target, in perspective projection.
set_display_mode()Switches the display mode of viewport (None = the active one).
zoom_extents()Zooms viewport (None = the active one) to the extents of the visible geometry.

ra.view.capture()

ra.view.capture(path: str, width=None, height=None, viewport=None) -> str

Captures viewport (None = 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).

ParameterType
pathstrrequired
widthintoptional — None = the tool default
heightintoptional — None = the tool default
viewportstroptional — None = the tool default

ra.view.describe()

ra.view.describe() -> str

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

ra.view.import_named_views()

ra.view.import_named_views(path: str) -> List[str]

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.

ParameterType
pathstrrequired

ra.view.restore_named_view()

ra.view.restore_named_view(name: str, viewport=None)

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

ParameterType
namestrrequired
viewportstroptional — None = the tool default

ra.view.save_named_view()

ra.view.save_named_view(name: str, viewport=None)

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

ParameterType
namestrrequired
viewportstroptional — None = the tool default

ra.view.set_camera()

ra.view.set_camera(location: PointLike, target: PointLike, lens_mm=None, viewport=None)

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

ParameterType
locationPointLikerequired
targetPointLikerequired
lens_mmfloatoptional — None = the tool default
viewportstroptional — None = the tool default

ra.view.set_display_mode()

ra.view.set_display_mode(mode: str, viewport=None)

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

ParameterType
modestrrequired
viewportstroptional — None = the tool default

ra.view.zoom_extents()

ra.view.zoom_extents(viewport=None)

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

ParameterType
viewportstroptional — None = the tool default