You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 15 Next »

Table of Contents

 

In V-Ray it is now possible to access the underlying scene plugins via the Rhino script tools.
A script access manual is provided with the installation of V-Ray. It can be found at the V-Ray for Rhino root folder C:\Program Files\Chaos Group\V-Ray\V-Ray for Rhinoceros\VRayForRhinoObjectModel.html.

To use the V-Ray for Rhino wrapper module, add a new Python Module Search path pointing to C:\Program Files\Chaos Group\V-Ray\V-Ray for Rhinoceros.

Alternatively, copy the rhVRay.py file from C:\Program Files\Chaos Group\V-Ray\V-Ray for Rhinoceros to %APPDATA%\McNeel\Rhinoceros\6.0\scripts and %APPDATA%\McNeel\Rhinoceros\6.0\scripts.


Due to the way V-Ray for Rhino communicates with its UI, certain "user data" parameters are employed while the actual scene parameters are set accordingly only at render time.
The precise names of such "user data" parameters can be found listed in exported V-Ray files:

  • for Settings - export a .vropt file
  • for Assets - export an asset of the required type as a .vrmat file

Their parameter handlers contain isUserData="1".

To set a parameter value in the V-Ray UI via a script, the "user data" counterpart must be used. Otherwise, the change will only affect the V-Ray scene.

 

ParamTypes


Enumeration

NameValueDescription
T_UNKNOWN0Undefined type. Generally an error
T_INTEGER1Single precision floating point number
T_FLOAT2Single precision floating point number
T_STRING4Character string value
T_BOOL8Boolean value
T_TRANSFORM16Transformation value, consisting of a matrix and a vector. Equivalent to 12-element single precision floating point array
T_MATRIX32Matrix value. Equivalent to 9-element single precision floating point array
T_VECTOR64Vector value. Equivalent to 3-element single precision floating point array
T_COLOR128RGB float color value. Equivalent to 3-element single precision floating point array
T_ACOLOR256RGBA float color value. Equivalent to 4-element single precision floating point array
T_LIST32768Binary OR-ed with the other type indicates that the value is list of values of that type

 


RenderModes

Enumeration

Property NameValueDescription
RM_PRODUCTION0

Renders in production mode

RM_INTERACTIVE1

Renders in interactive mode

RM_CLOUD2

Starts the current render job on the Cloud

RM_LAST3Repeats the last render

 


RenderEngines

Enumeration

Property NameValueDescription
RE_CPU0

Renders on the CPU

RE_CUDA1

Renders on the GPU and/or CPU using CUDA

RE_RTX2

Renders on the GPU using RTX Optix

 



RhinoScriptSceneParam


Represents a reference to a NeUI plugin parameter

Property NameDescription
ValueGets or sets the value of the parameter. Must conform with the value type
TypeReturns the data type of the parameter. Can be OR-ed with ParamTypes::T_LIST
TypeAsStringReturns the data type of the parameter as string

Value

Gets or sets the value of the parameter. Must conform with the value type


Syntax:

VARIANT Value

Examples:



Option Explicit

Dim vray, imgWidthParam, imgWidth
Set vray = Rhino.GetPlugInObject("V-Ray for Rhino")
Set imgWidthParam = vray.Scene.Plugin("/SettingsOutput").Param("img_width")
imgWidth = imgWidthParam.Value
imgWidthParam.Value = imgWidth * 2


import rhinoscriptsyntax as rs

vray = rs.GetPlugInObject("V-Ray for Rhino")
param = vray.Scene().Plugin("/SettingsOutput").Param("img_width")
imgWidth = param.Value()
param.Value = imgWidth * 2


import rhVRay as vray

vray.Scene.SettingsOutput.img_width *= 2

 


Type

Returns the data type of the parameter. Can be OR-ed with ParamTypes::T_LIST

 

Syntax:

ParamTypes Type

Examples:

 


Option Explicit

Dim vray, imgWidthParam, paramType
Set vray = Rhino.GetPlugInObject("V-Ray for Rhino")
Set imgWidthParam = vray.Scene.Plugin("/SettingsOutput").Param("img_width")
paramType = imgWidthParam.Type


import rhinoscriptsyntax as rs

vray = rs.GetPlugInObject("V-Ray for Rhino")
param = vray.Scene().Plugin("/SettingsOutput").Param("img_width")
paramType = param.Type()


import rhVRay as vray

paramType = vray.Scene.SettingsOutput.Param("img_width").Type

 


 

TypeAsString

Returns the data type of the parameter. Can be OR-ed with ParamTypes::T_LIST

 

Syntax:

BSTR TypeAsString

Examples:

 

 

Option Explicit

Dim vray, imgWidthParam, paramType
Set vray = Rhino.GetPlugInObject("V-Ray for Rhino")
Set imgWidthParam = vray.Scene.Plugin("/SettingsOutput").Param("img_width")
paramType = imgWidthParam.TypeAsString


import rhinoscriptsyntax as rs

vray = rs.GetPlugInObject("V-Ray for Rhino")
param = vray.Scene().Plugin("/SettingsOutput").Param("img_width")
paramType = param.TypeAsString()

 

import rhVRay as vray

 

paramType = vray.Scene.SettingsOutput.Param("img_width").TypeAsString

 


RhinoScriptScenePlugin


Represents a reference to a NeUI plugin

Property NameDescription
NameReturns the name of the plugin
TypeReturns the type of the plugin
ClassReturns the class of the plugin

 

 

Method NameDescription
ParamReturns the class of the plugin

 

 

Name

Returns the name of the plugin


Syntax:

BSTR Name

Examples:

 

 

Option Explicit

Dim vray, pluginName
Set vray = Rhino.GetPlugInObject("V-Ray for Rhino")
pluginName = vray.Scene.Plugin("/SettingsOutput").Name


import rhinoscriptsyntax as rs

vray = rs.GetPlugInObject("V-Ray for Rhino")
pluginName = vray.Scene().Plugin("/SettingsOutput").Name()

 

import rhVRay as vray

pluginName = vray.Scene.SettingsOutput.Name

 


 

Type

Returns the type of the plugin


Syntax:

BSTR Type

Examples:

 

 

Option Explicit

Dim vray, pluginType
Set vray = Rhino.GetPlugInObject("V-Ray for Rhino")
pluginType = vray.Scene.Plugin("/SettingsOutput").Type

 

import rhinoscriptsyntax as rs

vray = rs.GetPlugInObject("V-Ray for Rhino")
pluginType = vray.Scene().Plugin("/SettingsOutput").Type()

 

import rhVRay as vray

pluginType = vray.Scene.SettingsOutput.Type

 


Class

Returns the class of the plugin

Syntax:

BSTR Class

Examples:

 

Option Explicit

Dim vray, pluginClass
Set vray = Rhino.GetPlugInObject("V-Ray for Rhino")
pluginClass = vray.Scene.Plugin("/SettingsOutput").Class

 

import rhinoscriptsyntax as rs

vray = rs.GetPlugInObject("V-Ray for Rhino")
pluginClass = vray.Scene().Plugin("/SettingsOutput").Class()

 

import rhVRay as vray

pluginClass = vray.Scene.SettingsOutput.Class

 


 

Param

Returns the parameter of the plugin


Syntax:

RhinoScriptSceneParam *Param(
[in, string] BSTR paramName
)
 

Parameters: 

[in] BSTR paramName : Name of the parameter to get

 

Return: 

RhinoScriptSceneParam

Examples:

 

 

Option Explicit

Dim vray, imgWidth
Set vray = Rhino.GetPlugInObject("V-Ray for Rhino")
imgWidth = vray.Scene.Plugin("/SettingsOutput").Param("img_width")


import rhinoscriptsyntax as rs

vray = rs.GetPlugInObject("V-Ray for Rhino")
pluginClass = vray.Scene().Plugin("/SettingsOutput").Class()

 

import rhVRay as vray

imgWidth = vray.Scene.SettingsOutput.Param("img_width")

 


RhinoScriptScene


Represents the NeUI scene

Method NameDescription
PluginReturns a reference to a given scene plugin
PluginsReturns an array of references to all plugins in the scene
PluginsByClassReturns an array of references to all plugins of a given class in the scene
PluginsByTypeReturns an array of references to all plugins of a given type in the scene
RefreshRefreshes the NeUI window
MaterialsGets an array of all material plugins in the scene
LightsGets an array of all light plugins in the scene
SettingsGets an array of all settings plugins in the scene
SpecialObjectsGets an array of all special object plugins (proxies, clippers, furs and infinite planes) in the scene

 


Plugin

Returns a reference to a given scene plugin


Syntax:

RhinoScriptScenePlugin* Plugin(
[in, string] BSTR pluginName
)

 

Parameters:

[in] BSTR pluginName : Name of the plugin to get

 

Return:

RhinoScriptScenePlugin

Examples:


 

Option Explicit

Dim vray, settingsOutput
Set vray = Rhino.GetPlugInObject("V-Ray for Rhino")
Set settingsOutput = vray.Scene.Plugin("/SettingsOutput")

 

import rhinoscriptsyntax as rs

vray = rs.GetPlugInObject("V-Ray for Rhino")
settingsOutput = vray.Scene().Plugin("/SettingsOutput")

 

import rhVRay as vray

settingsOutput = vray.Scene.Plugin("/SettingsOutput")

 


Plugins

Returns an array of references to all plugins in the scene


Syntax:

VARIANT Plugins()


Return:

VARIANT array of RhinoScriptScenePlugin objects

Examples:


 

Option Explicit

Dim vray, plugins
Set vray = Rhino.GetPlugInObject("V-Ray for Rhino")
plugins = vray.Scene.Plugins

 

import rhinoscriptsyntax as rs

vray = rs.GetPlugInObject("V-Ray for Rhino")
plugins = vray.Scene().Plugins()

 

import rhVRay as vray

plugins = vray.Scene.Plugins

 


PluginsByClass

Returns an array of references to all plugins of a given class in the scene

 

Syntax:

VARIANT PluginsByClass(
[in, string] BSTR className

[in] VARIANT_BOOL onlyTopLevel

)


Parameters:

[in] BSTR className : Name of the plugins class

[in] VARIANT_BOOL onlyTopLevel : VARIANT_TRUE to consider only top-level plugins, or all plugins otherwise. VARIANT_TRUE by default

 

Return:

VARIANT array of RhinoScriptScenePlugin
Examples:


 

Option Explicit

Dim vray, vrayMtl
Set vray = Rhino.GetPlugInObject("V-Ray for Rhino")
vrayMtl = vray.Scene.PluginsByClass("MtlSingleBRDF")

 

import rhinoscriptsyntax as rs

vray = rs.GetPlugInObject("V-Ray for Rhino")
vrayMtl = vray.Scene().PluginsByClass("MtlSingleBRDF")

 

import rhVRay as vray

vrayMtlAssets = vray.Scene.PluginsByClass("MtlSingleBRDF", True)
vrayMtlAll = vray.Scene.PluginsByClass("MtlSingleBRDF", False)

 


PluginsByType

Returns an array of references to all plugins of a given type in the scene

 

Syntax:

VARIANT PluginsByType(
[in, string] BSTR typeName
[in] VARIANT_BOOL onlyTopLevel
)


Parameters:

[in] BSTR typeName : Name of the plugins type

[in] VARIANT_BOOL onlyTopLevel : VARIANT_TRUE to consider only top-level plugins, or all plugins otherwise. VARIANT_TRUE by default

 

Return:

VARIANT array of RhinoScriptScenePlugin
Examples:


 

Option Explicit

Dim vray, mtls
Set vray = Rhino.GetPlugInObject("V-Ray for Rhino")
mtls = vray.Scene.PluginsByType("material")
all_mtl_plugins = vray.Scene.PluginsByType("material", False)

 

import rhinoscriptsyntax as rs

vray = rs.GetPlugInObject("V-Ray for Rhino")
mtls = vray.Scene().PluginsByType("material")
all_mtl_plugins = vray.Scene.PluginsByType("material", False)

 

import rhVRay as vray

mtls = vray.Scene.PluginsByType("material", True)
all_mtl_plugins = vray.Scene.PluginsByType("material", False)

 


Refresh

Refreshes the NeUI window

 

Syntax:

void Refresh()
Examples:


 

Option Explicit

Dim vray
Set vray = Rhino.GetPlugInObject("V-Ray for Rhino")
vray.Scene.Refresh

 

import rhinoscriptsyntax as rs

vray = rs.GetPlugInObject("V-Ray for Rhino")
vray.Scene().Refresh()

 

import rhVRay as vray

vray.Scene.Refresh



Materials

Gets an array of all material plugins in the scene

 

Syntax:

VARIANT Materials()

 

Return:

VARIANT array of RhinoScriptScenePlugin
Examples:


 

Option Explicit

Dim vray, materials
Set vray = Rhino.GetPlugInObject("V-Ray for Rhino")
materials = vray.Scene.Materials

 

import rhinoscriptsyntax as rs

vray = rs.GetPlugInObject("V-Ray for Rhino")
materials = vray.Scene().Materials()

 

import rhVRay as vray

materials = vray.Scene.Materials 



Lights

Gets an array of all light plugins in the scene

 

Syntax:

VARIANT Lights()

 

Return:

VARIANT array of RhinoScriptScenePlugin
Examples:


 

Option Explicit

Dim vray, lights
Set vray = Rhino.GetPlugInObject("V-Ray for Rhino")
lights = vray.Scene.Lights

 

import rhinoscriptsyntax as rs

vray = rs.GetPlugInObject("V-Ray for Rhino")
lights = vray.Scene().Lights()

 

import rhVRay as vray

lights = vray.Scene.Lights



Settings

Gets an array of all settings plugins in the scene

 

Syntax:

VARIANT Settings()


Return:

VARIANT array of RhinoScriptScenePlugin
Examples:

 

 

Option Explicit

Dim vray, settings
Set vray = Rhino.GetPlugInObject("V-Ray for Rhino")
settings = vray.Scene.Settings

 

import rhinoscriptsyntax as rs

vray = rs.GetPlugInObject("V-Ray for Rhino")
settings = vray.Scene().Settings()

 

import rhVRay as vray

settings = vray.Scene.Settings



SpecialObjects

Gets an array of all special object plugins (proxies, clippers, furs and infinite planes) in the scene


Syntax:

VARIANT SpecialObjects()


Return:

VARIANT array of RhinoScriptScenePlugin
Examples:


 

Option Explicit

Dim vray, so
Set vray = Rhino.GetPlugInObject("V-Ray for Rhino")
so = vray.Scene.SpecialObjects

 

import rhinoscriptsyntax as rs

vray = rs.GetPlugInObject("V-Ray for Rhino")
so = vray.Scene().SpecialObjects()

 

import rhVRay as vray

specialObj = vray.Scene.SpecialObjects

 


LoadSettings

Loads a given .vropt file into the scene. The default file will be loaded on failure


Syntax:

VARIANT_BOOL LoadSettings(
[in, string] const BSTR fileName
)

Return:

None-zero if succeeded, zero if failed
Examples:


 

Option Explicit

Dim vray, success Set vray = Rhino.GetPlugInObject("V-Ray for Rhino")
success = vray.Scene.LoadSettings "Rhino Default.vropt"

 

import rhinoscriptsyntax as rs

vray = rs.GetPlugInObject("V-Ray for Rhino")
success = vray.Scene().LoadSettings("Rhino Default.vropt")

 

import rhVRay as vray

success = vray.Scene.LoadSettings("Rhino Default.vropt")

 

 

 

SaveSettings

Saves the current settings into a given .vropt file

 

Syntax:

VARIANT_BOOL SaveSettings(
[in, string] const BSTR fileName
)

Return:

None-zero if succeeded, zero if failed
Examples:


 

Option Explicit

Dim vray, success
Set vray = Rhino.GetPlugInObject("V-Ray for Rhino")

success = vray.Scene.SaveSettings "settings.vropt"

 

import rhinoscriptsyntax as rs

vray = rs.GetPlugInObject("V-Ray for Rhino")
success = vray.Scene().SaveSettings("settings.vropt")

 

import rhVRay as vray

success = vray.Scene.SaveSettings("settings.vropt")

 


 

RhinoScriptObject

Represents the NeUI scene

 

Property NameDescription
SceneReturns the currently active scene
Method NameDescription
Render

Starts a V-Ray render

CancelRenderStops the current rendering process
GetSceneValue

Gets a stringified value from a scene plugin. This method is a shortcut to getting a scene parameter and calling GetValue() ot in

SetSceneValue

Sets a stringified value to the scene. Call RefreshUI to update the NeUI window

RefreshUI

Refreshes the NeUI asset manager window

 


Scene

Returns the currently active scene

 

Syntax:

RhinoScriptScene* Scene


Examples:

 

Option Explicit

Dim vray, scene
Set vray = Rhino.GetPlugInObject("V-Ray for Rhino")
Set scene = vray.Scene

 

import rhinoscriptsyntax as rs

vray = rs.GetPlugInObject("V-Ray for Rhino")
scene = vray.Scene()

 

import rhVRay as vray

scene = vray.Scene

 


Render

Starts a V-Ray render

 

Syntax:

void Render(
[in] RenderModes mode,
[in] RenderEngines engine,
[in] int timeout
)

Parameters:

[in] RenderModes mode : Specifies the mode the render job shall be executed in

[in] RenderEngines engine : Specifies the render engine to use for the current render job

[in] int timeout : Specifies whether the current render job shall be executed synchronously or asynchronously.
Use -1 for syncrhonous renders, and >=0 for specific wait timeout in milliseconds


Examples:

 

 

Option Explicit

Dim vray
Set vray = Rhino.GetPlugInObject("V-Ray for Rhino")
Call vray.Render(0, 0, -1)

 

import rhinoscriptsyntax as rs

vray = rs.GetPlugInObject("V-Ray for Rhino")
vray.Render(0, 0, -1)

 

import rhVRay as vray

vray.Render(0,0,-1)

 


CancelRender

Stops the current rendering process

 

Syntax:

void CancelRender()
Examples:

 

 

Option Explicit

Dim vray
Set vray = Rhino.GetPlugInObject("V-Ray for Rhino")
vray.CancelRender

 

import rhinoscriptsyntax as rs

vray = rs.GetPlugInObject("V-Ray for Rhino")
vray.CancelRender()

 

import rhVRay as vray

vray.CancelRender()

 


GetSceneValue

Gets a stringified value from a scene plugin. This method is a shortcut to getting a scene parameter and calling GetValue() ot in

 

Syntax:

BSTR GetSceneValue(
[in, string]BSTR pluginName,
[in, string]BSTR paramName,
)

 

Parameters:

[in] BSTR pluginName : Name of the plugin

[in] BSTR paramName : Name of the parameter

 

Return:

Returns the value of the given plugins parameter as string
Examples:


 

Option Explicit

Dim vray, imageWidth, imageHeight
Set vray = Rhino.GetPlugInObject("V-Ray for Rhino")
imageWidth = CInt(vray.getSceneValue("/SettingsOutput", "img_width"))
imageHeight = CInt(vray.getSceneValue("/SettingsOutput", "img_height"))

 

import rhinoscriptsyntax as rs

vray = rs.GetPlugInObject("V-Ray for Rhino")
imageWidth = int(vray.getSceneValue("/SettingsOutput", "img_width"))
imageHeight = int(vray.getSceneValue("/SettingsOutput", "img_height"))

 

import rhVRay as vray

imageWidth = int(vray.GetSceneValue("/SettingsOutput", "img_width"))
imageHeight = int(vray.GetSceneValue("/SettingsOutput", "img_height"))

 


SetSceneValue

Sets a stringified value to the scene. Call RefreshUI to update the NeUI window

 

Syntax:

VARIANT_BOOL SetSceneValue(
[in, string]BSTR pluginName,
[in, string]BSTR paramName,
[in, string]BSTR value
)

 

Parameters:

[in] BSTR pluginName : Name of the plugin

[in] BSTR paramName : Name of the parameter

[in] BSTR value : Stringified value to set

 

Return:

Returns True if setting was successful, False otherwise
Examples:

 

 

Option Explicit

Dim vray
Set vray = Rhino.GetPlugInObject("V-Ray for Rhino")
vray.SetSceneValue "/SettingsOutput", "img_width", 800

 

import rhinoscriptsyntax as rs

vray = rs.GetPlugInObject("V-Ray for Rhino")
vray.SetSceneValue("/SettingsOutput", "img_width", 800)

 

import rhVRay as vray

vray.SetSceneValue("/SettingsOutput", "img_width", 800)

 


RefreshUI

Refreshes the NeUI asset manager window


Syntax:

void RefreshUI()
Examples:


 

Option Explicit

Dim vray
Set vray = Rhino.GetPlugInObject("V-Ray for Rhino")
vray.RefreshUI

 

import rhinoscriptsyntax as rs

vray = rs.GetPlugInObject("V-Ray for Rhino")
vray.RefreshUI()

 

import rhVRay as vray

vray.RefreshUI()

 

 

SpecialObjects

Gets an array of all special object plugins (proxies, clippers, furs and infinite planes) in the scene


Syntax:

VARIANT SpecialObjects()


Return:

VARIANT array of RhinoScriptScenePlugin
Examples:


 

Option Explicit

Dim vray, so
Set vray = Rhino.GetPlugInObject("V-Ray for Rhino")
so = vray.Scene.SpecialObjects

 

import rhinoscriptsyntax as rs

vray = rs.GetPlugInObject("V-Ray for Rhino")
so = vray.Scene().SpecialObjects()

Was this helpful?