Skip to content

Scripting API

Scene & effects

from ArtisanPlugin.Scripting import RealtimeRenderApi as rtr

The viewer’s look - background, lighting, and a full post-processing stack - is one big options object, and this page is the scripted way into it. Two curated calls cover the common moves; the generic SetViewerOption reaches everything else. All of them fire and forget, and none of them touches the Rhino document.

Background

rtr.SetViewerBackground("#1a1a2e", "#0b0b14")   # -> None  (top, bottom)
rtr.SetViewerBackground("white")                # -> None  (top only)

Sets the background gradient. Colors are CSS colors - hex or named. Pass one or both ends; passing neither throws “Pass at least one color.”

Lighting environment

rtr.SetViewerEnvironment("studio", 1.2)                          # preset + intensity
rtr.SetViewerEnvironment("https://cdn.example.com/loft.hdr")     # custom HDRI
ParameterDefaultMeaning
presetOrUrlrequiredA preset name, or an HDR/EXR url
intensity0 (untouched)Environment intensity; 1 is neutral

The presets, exactly as the viewer ships them: studio, sunset, dawn, night, warehouse, forest, apartment, city, park, lobby. Anything that is not one of those and does not look like a url (starts with http, or ends in .hdr/.exr) throws listing the valid names. intensity is only written when greater than 0.

Any option: SetViewerOption

rtr.SetViewerOption("effectComposerBloomEnabled", "true")     # -> None
rtr.SetViewerOption("effectComposerBloomIntensity", "0.6")
rtr.SetViewerOption("autoRotate", "true")
ParameterDefaultMeaning
pathrequiredThe option key
valuerequiredParsed as bool, number or string, in that order

"true"/"false" become booleans, anything numeric becomes a number, everything else stays a string ("#ffffff"). The option groups worth knowing:

GroupKeys
BevelbevelEnabled, bevelRadius, bevelStrength, bevelEdgeAmplify
Contact shadowjewelryShadowEnabled, …Darkness, …Blur, …Scale, …Falloff, …Color, …LightX/Y/Z
Ambient occlusioneffectComposerN8aoEnabled, …Radius, …Intensity
Depth of fieldeffectComposerDepthOfFieldEnabled, …FocusDistance, …FocalLength, …BokehScale, …Autofocus
BloomeffectComposerBloomEnabled, …Intensity, …LuminanceThreshold, …Radius
VignetteeffectComposerVignetteEnabled, …Offset, …Darkness
Color gradingeffectComposerBrightnessContrast*, effectComposerHueSaturation*
CausticscausticsEnabled, causticsIntensity, causticsColor, causticsIor
Studio lightskeyLightEnabled/Intensity/Color, fillLight*, rimLight*
MiscautoRotate, autoRotateSpeed, toneMappingExposure, environmentBlur

An unknown key is not an error - the page just stores it and nothing changes. Spell carefully.

A batch of options: SetViewerOptions

rtr.SetViewerOptions("""{
  "effectComposerBloomEnabled": true,
  "effectComposerBloomIntensity": 0.6,
  "effectComposerVignetteEnabled": true,
  "jewelryShadowEnabled": true
}""")                                          # -> None

Applies several options in one round trip. The argument is a JSON object of keys to values; anything else throws “optionsJson must be a JSON object of option keys to values.”, and an empty object throws “optionsJson has no options.” Values here are real JSON types, so no string-parsing rules apply.