Skip to content

Python package

ra.realtime_render

The web Realtime Render viewer: open, update, camera, materials, screenshots.

import rhinoartisan as ra

Wraps ArtisanPlugin.Scripting.RealtimeRenderApi.

Functions

Function
capture_views()Captures the 8 standard orbital views (front, back, left, right, three-quarter x2, top, bottom) as PNGs into folder — one call, camera restored afterwards.
edit_viewer_material()Live-edits a catalog material everywhere it is currently applied: color (CSS color), roughness 0-1, ior (gems, ~1.4-2.4), opacity 0-1.
get_viewer_items()JSON array with the viewer’s parts and their current materials ([{uuid, material, …}]).
record_turntable()One-call 360: turns auto-rotation on, records seconds of video to path, and schedules the rotation back off inside the page when the recording ends — the script needs no sleeps or timers.
set_material_by_layer()Applies a viewer catalog material to every part on a layer.
set_viewer_background()Sets the viewer’s background gradient.
set_viewer_camera()Places the VIEWER camera at position looking at target (viewer/GLB coordinates, which match the Rhino model in mm).
set_viewer_camera_preset()Moves the VIEWER camera to a named preset.
set_viewer_environment()Sets the lighting environment: a preset name (studio, sunset, dawn, night, warehouse, forest, apartment, city, park, lobby) or an HDR/EXR URL.
set_viewer_material()Changes one part’s material in the viewer.
set_viewer_option()Sets ANY single viewer option by its dot-path key — backgrounds, bevel, jewelry shadows, AO, depth of field, bloom, vignette, caustics, studio lights, auto_rotate…
set_viewer_options()Applies a batch of viewer options in one call.
show_realtime_render()Opens the Realtime Render window (or activates it when already open), same as the ArtisanRealtimeRender command — which is hidden from the command list, so this is the only scriptable way in.
start_video_recording()Starts recording the viewer to a video file.
stop_video_recording()Stops a manual recording started with seconds = 0; the file is then written to the path given to StartVideoRecording.
update_render()Re-exports the current document to the viewer (the ArtisanRenderUpdate command).
viewer_screenshot()Saves a PNG of the current viewer frame to path and returns the full path written (“.png” appended when missing).
viewer_zoom_extents()Frames the whole model in the viewer.

ra.realtime_render.capture_views()

ra.realtime_render.capture_views(folder: str, width=None, height=None) -> str

Captures the 8 standard orbital views (front, back, left, right, three-quarter x2, top, bottom) as PNGs into folder — one call, camera restored afterwards. Returns the paths written, one per line. Slow: expect a few seconds; the call waits up to 2 minutes.

ParameterType
folderstrrequired
widthintoptional — None = the tool default
heightintoptional — None = the tool default

ra.realtime_render.edit_viewer_material()

ra.realtime_render.edit_viewer_material(material_name: str, color=None, roughness=None, ior=None, opacity=None)

Live-edits a catalog material everywhere it is currently applied: color (CSS color), roughness 0-1, ior (gems, ~1.4-2.4), opacity 0-1. Pass None/negative to leave a property untouched. The edit is ephemeral — re-applying the material from the catalog resets it.

ParameterType
material_namestrrequired
colorstroptional — None = the tool default
roughnessfloatoptional — None = the tool default
iorfloatoptional — None = the tool default
opacityfloatoptional — None = the tool default

ra.realtime_render.get_viewer_items()

ra.realtime_render.get_viewer_items() -> str

JSON array with the viewer’s parts and their current materials ([{uuid, material, …}]). Call this FIRST to learn the part names (uuids) to pass to SetViewerMaterial.

ra.realtime_render.record_turntable()

ra.realtime_render.record_turntable(path: str, seconds=None, width=None, height=None, frame_rate=None) -> str

One-call 360: turns auto-rotation on, records seconds of video to path, and schedules the rotation back off inside the page when the recording ends — the script needs no sleeps or timers. Returns the path armed; the file appears when the recording finishes.

ParameterType
pathstrrequired
secondsfloatoptional — None = the tool default
widthintoptional — None = the tool default
heightintoptional — None = the tool default
frame_rateintoptional — None = the tool default

ra.realtime_render.set_material_by_layer()

ra.realtime_render.set_material_by_layer(layer_name: str, material_name: str) -> int

Applies a viewer catalog material to every part on a layer. layer_name matches the viewer item’s layer or name, case-insensitive and treating spaces and underscores as equal — so “METAL_01”, “metal 01” and “Metal 01” all hit the Rhino layer “Metal 01”. Returns how many parts changed; throws listing the available layers when nothing matches. Viewer-only: the Rhino document is untouched.

ParameterType
layer_namestrrequired
material_namestrrequired

ra.realtime_render.set_viewer_background()

ra.realtime_render.set_viewer_background(top_color: str, bottom_color=None)

Sets the viewer’s background gradient. Colors are CSS colors (“#1a1a2e”, “white”…). Pass None/empty to leave one end unchanged.

ParameterType
top_colorstrrequired
bottom_colorstroptional — None = the tool default

ra.realtime_render.set_viewer_camera()

ra.realtime_render.set_viewer_camera(position: PointLike, target: PointLike)

Places the VIEWER camera at position looking at target (viewer/GLB coordinates, which match the Rhino model in mm).

ParameterType
positionPointLikerequired
targetPointLikerequired

ra.realtime_render.set_viewer_camera_preset()

ra.realtime_render.set_viewer_camera_preset(preset: str)

Moves the VIEWER camera to a named preset. Valid presets: front, back, left, right, top, bottom, three-quarter, three-quarter-left, detail, dramatic-low. The preset frames the model automatically.

ParameterType
presetstrrequired

ra.realtime_render.set_viewer_environment()

ra.realtime_render.set_viewer_environment(preset_or_url: str, intensity=None)

Sets the lighting environment: a preset name (studio, sunset, dawn, night, warehouse, forest, apartment, city, park, lobby) or an HDR/EXR URL. intensity > 0 also sets the environment intensity (1 = neutral).

ParameterType
preset_or_urlstrrequired
intensityfloatoptional — None = the tool default

ra.realtime_render.set_viewer_material()

ra.realtime_render.set_viewer_material(part_uuid: str, material_name: str)

Changes one part’s material in the viewer. part_uuid comes from GetViewerItems(); material_name is a viewer catalog name (e.g. “YELLOW_GOLD”, “WHITE_GOLD”, “PLATINUM”, “DIAMOND”, “RUBY”). Viewer-only: the Rhino document is not modified.

ParameterType
part_uuidstrrequired
material_namestrrequired

ra.realtime_render.set_viewer_option()

ra.realtime_render.set_viewer_option(path: str, value: str)

Sets ANY single viewer option by its dot-path key — backgrounds, bevel, jewelry shadows, AO, depth of field, bloom, vignette, caustics, studio lights, auto_rotate… value is parsed as bool, number or string (“True”, “0.4”, “#ffffff”).

ParameterType
pathstrrequired
valuestrrequired

ra.realtime_render.set_viewer_options()

ra.realtime_render.set_viewer_options(options_json: str)

Applies a batch of viewer options in one call. options_json is a JSON object of option keys to values, e.g. {“effect_composer_bloom_enabled”:True,“effect_composer_bloom_intensity”:0.6}.

ParameterType
options_jsonstrrequired

ra.realtime_render.show_realtime_render()

ra.realtime_render.show_realtime_render() -> bool

Opens the Realtime Render window (or activates it when already open), same as the ArtisanRealtimeRender command — which is hidden from the command list, so this is the only scriptable way in.

ra.realtime_render.start_video_recording()

ra.realtime_render.start_video_recording(path: str, seconds=None, width=None, height=None, frame_rate=None) -> str

Starts recording the viewer to a video file. seconds > 0 stops and saves automatically after that long; 0 records until StopVideoRecording(). The finished file lands at path (the window reroutes the viewer’s download there). The viewer picks the codec: mp4 (h264) when the OS supports it, webm otherwise — keep “.mp4”.

ParameterType
pathstrrequired
secondsfloatoptional — None = the tool default
widthintoptional — None = the tool default
heightintoptional — None = the tool default
frame_rateintoptional — None = the tool default

ra.realtime_render.stop_video_recording()

ra.realtime_render.stop_video_recording()

Stops a manual recording started with seconds = 0; the file is then written to the path given to StartVideoRecording. Saving is asynchronous — give it a moment before reading the file.

ra.realtime_render.update_render()

ra.realtime_render.update_render()

Re-exports the current document to the viewer (the ArtisanRenderUpdate command). The export runs in the background; this returns as soon as it is queued. Requires the Realtime Render window to be open — throws a clear error otherwise (the command only logged it, which a script would never see).

ra.realtime_render.viewer_screenshot()

ra.realtime_render.viewer_screenshot(path: str) -> str

Saves a PNG of the current viewer frame to path and returns the full path written (“.png” appended when missing).

ParameterType
pathstrrequired

ra.realtime_render.viewer_zoom_extents()

ra.realtime_render.viewer_zoom_extents()

Frames the whole model in the viewer.