VrayScript Node Overview
Using this node you can use the V-Ray scene access python API. This API allows you to modify the V-Ray scene after it is translated by the V-Ray for Katana translator, and before it is rendered and/or exported to a .vrscene file. Note that the V-Ray scene may be quite different from its representation in Katana. As such, some knowledge about the way V-Ray translates various Katana constructs may be required. It would be best to study .vrscene files exported by V-Ray for Katana.
The scene access API allows you to expand the V-Ray for Katana translator by providing custom translation for constructs that are not recognized by V-Ray, or for modifying the scene before rendering without changing the original Katana scene.
The node has a single parameter where the python script should be entered. The script is executed right after the scene is translated, and before it is rendered and/or exported to a .vrscene file. Multiple script nodes can be used. The order of the execution will be the same as the order of the nodes in Katana's Nodegraph.
Available Python Functions and Classes
The declarations (and in some cases the implementations) for all the python functions and classes are available in the <plugin root folder>\scripts\vray.
The following python functions are available in the vray.utils module.
create(pluginType, pluginName) - create a plugin with the given name and type.
delete(pluginName) - delete a plugin with the given name.
findByName(pattern) - return a list of all plugins of a given type. pattern may contain wildcards.
findByType(pattern) - return a list of all plugins of a given type. pattern may contain wildcards.
getPluginParams(plugin, getValues=False , onlyExisting=False) - return a list of all available parameters for the given plugin. If getValues is True the value for each parameter is also returned. If onlyExisting is True, then only parameters that are actually set in the V-Ray scene are returned; otherwise all plugin parameters are returned and the ones that are not set in the V-Ray scene are listed with their default values.
getTypeParams(pluginType) - return a list of all parameters for a given plugin type.
addSceneContent(scenefile, prefix="") - load all plugins from the given .vrscene file and insert them in the current scene. You can optionally specify a prefix that will be prepended to every plugin's name. The scene file is loaded in a new namespace from the rest of the scene - if there are plugins that have the same name as other plugins in the scene, they remain as separate plugins.
appendSceneContent(scenefile, prefix="") - load all plugins from the given .vrscene file and append them to the current scene, with an optional prefix. The plugins are appended in the namespace of the last loaded scene, so if there are already existing plugins with the same names, the data for their parameters is appended to the existing plugins. This can be used to load multiple .vrscene files from the same animated sequence. Wildcards can be used to specify scene files.
The following python classes are available in the vray.utils module.
This class represents an instance of a V-Ray plugin in the scene.
duplicate(self, newName) - return a new plugin instance of the same type and with the same parameters.
get(self, paramName) - return the value of a parameter.
has(self, paramName) - check whether the plugin instance has a parameter with this name.
name(self) - return the name of the plugin instance.
params(self, getValues=False , onlyExisting=False ) - return a list of all available parameters for this plugin. If getValues is True the value for each parameter is also returned. If onlyExisting is True, then only parameters that are actually set in the V-Ray scene are returned; otherwise all plugin parameters are returned and the ones that are not set in the V-Ray scene are listed with their default values.
output(self, paramName) - return a reference to a plugin output parameter, which can be set as a value for parameters of other plugins.
set(self, paramName, value) - set the value of a parameter.
type(self) - get the type of the plugin instance.
Classes Representing Plugin Parameter Values
Parameters of the V-Ray plugins in the scene can be simple numbers, or more complex data types. Simple values can be directly manipulated, whereas complex types are represented by a dedicated python class.
This class represents a reference to an output parameter of a V-Ray plugin. It is used whenever one plugin is connected to another plugin's output parameter.
This class represents a four-component color value (red, green, blue, alpha).
This class represents a three-component color value (red, green, blue).
This class represents a three-component vector or point in 3D space.
This class represents a 3x3 matrix.
This class represents a 3x4 transformation in 3D space.
Example: Changing the Color of Material and Moving a Node
This example script changes the color of the material of the first node in the scene (assuming the original material is a lambert one) and moves the node one unit up.
Example: Converting Meshes to Subdivision Surfaces
This example shows how to convert all regular meshes in the scene to subdivision surfaces.
Example: Instancing the First Node to Form a Helix
This example instances the first node in the scene a number of times to form a helix.
Example: Exporting and Changing Materials
This example exports several textures and materials and changes the material of an object.
Example: Combining the Contents of Several Scenes
This example adds the contents of several scenes and uses some of the newly created plugins.
Example: Modifying the Parameters
This example demonstrates how to change the value of a more complex parameter. For instance, the ignored_lights parameter of the SettingsLightLinker plugin is a list of several sub-lists of plugins. The first plugin in each list is a light plugin and the rest of the plugins are geometry nodes. This is how the parameter can be modified: