Skip to content

Scripting API

Capture

from ArtisanPlugin.Scripting import RealtimeRenderApi as rtr

Two ways to get pixels out of the viewer: one frame exactly as shown, or a full orbit of standard views for a product sheet. Both wait for the page, so both can time out - and both capture whatever the viewer is showing, so set materials and scene first and give it a beat after UpdateRender.

Screenshot

path = rtr.ViewerScreenshot(r"C:\out\hero")     # -> "C:\out\hero.png"
ParameterDefaultMeaning
pathrequiredDestination file; .png is appended when the extension is anything else

Saves a PNG of the current viewer frame and returns the full path actually written, which is what you should use afterwards rather than the string you passed. Path handling, in order: the path is resolved to an absolute path (a relative one resolves against Rhino’s working directory, not your script’s folder), .png is appended unless the extension already is .png, and the containing directory is created if it does not exist. An empty or whitespace path throws “A destination file path is required.”

The frame captured is at the window’s current size. When the page returns nothing - typically a viewer that has not finished loading - you get “The viewer did not return a screenshot.” Waits up to 15 seconds, then throws “The viewer did not respond in time.”

The 8 standard views

paths = rtr.CaptureViews(r"C:\out\ring-01", width=1600, height=1600)
print(paths)
# C:\out\ring-01\front.png
# C:\out\ring-01\right.png
# C:\out\ring-01\back.png
# ...
ParameterDefaultMeaning
folderrequiredDestination folder, created if missing
width0 (window size)Capture width in px
height0 (window size)Capture height in px

One call, eight PNGs: front, right, back, left, three-quarter-right, three-quarter-left, top, bottom - the viewer orbits the piece, shoots each angle, and restores your camera afterwards. Returns the paths written, one per line.

This is the slow call of the facade: expect a few seconds (more at large sizes), and it waits up to 2 minutes before throwing “The viewer did not finish capturing in time.” A page-side failure surfaces as “The viewer capture failed: …” with the page’s own error text.

The natural use is the product sheet:

rtr.ShowRealtimeRender()
rtr.UpdateRender()
rtr.SetMaterialByLayer("Metal 01", "WHITE_GOLD")
rtr.SetMaterialByLayer("Gems 01", "DIAMOND")

for sku, metal in [("R-1001-Y", "YELLOW_GOLD"), ("R-1001-W", "WHITE_GOLD"), ("R-1001-R", "ROSE_GOLD")]:
    rtr.SetMaterialByLayer("Metal 01", metal)
    rtr.CaptureViews(r"C:\out\%s" % sku, width=1600, height=1600)