V-Ray for Maya
Python Access to the Translated V-Ray Scene
This page provides information on the V-Ray scene access python API.
Last updated 19 September 2025
This page provides information on the V-Ray scene access python API.
Overview
The V-Ray scene access python API allows you to modify the V-Ray scene after it is translated by the V-Ray for Maya 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 Maya. As such, some knowledge about the way V-Ray translates various Maya constructs may be required. It would be best to study .vrscene files exported by V-Ray for Maya.
The scene access API allows you to expand the V-Ray for Maya 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 Maya scene.
You can specify the post-translate python script to be executed in the VRayCommon tab of the Render Settings dialog, in the MEL/Python callbacks rollout. The script is executed right after the scene is translated, and before it is rendered and/or exported to a .vrscene file. At present, when rendering an animation, the script is executed just once, before any frame is rendered.
For more information on various types of script access , see the Scripting page.
UI Path: ||Render Settings window|| > Common tab > MEL/Python callbacks rollout


Available Python Functions and Classes
The declarations (and in some cases the implementations) for all the python functions and classes are available in the C:\Program Files\Autodesk\Maya20xx\vray\scripts\vray.
Functions
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 name. 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.
exportTexture(texureName) – export the texture from the Maya scene and return the exported plugin. This function can be useful if the texture hasn't been exported while translating the scene.
exportMaterial(materialName) – export the material from the Maya scene and return the exported plugin. This function can be useful if the material hasn't been exported while translating the scene.
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.
Classes
The following python classes are available in the vray.utils module.
Plugin
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.
PluginOutput
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.
AColor
This class represents a four-component color value (red, green, blue, alpha).
Color
This class represents a three-component color value (red, green, blue).
Vector
This class represents a three-component vector or point in 3D space.
Matrix
This class represents a 3x3 matrix.
Transform
This class represents a 3x4 transformation in 3D space.
V-Ray Plugin Parameters Reference
You can find the list of all V-Ray plugins and their respective parameters with short description in the V-Ray for Maya instalation:
where Maya20xx is the installed Maya version.
Examples
Example: Overriding All Materials in the Scene with Grey
This example overrides the materials of all objects in the scene with a grey diffuse material.
<code data-v-c2b1f83f=""><span data-v-c2b1f83f="" class="line">from vray.utils import *</span><span data-v-c2b1f83f="" class="line"> </span><span data-v-c2b1f83f="" class="line"># create a diffuse BRDF that will be used for override</span><span data-v-c2b1f83f="" class="line">diffuseBRDF=create("BRDFDiffuse", "_overrideBRDF")</span><span data-v-c2b1f83f="" class="line">diffuseBRDF.set("color", Color(0.5, 0.5, 0.5))</span><span data-v-c2b1f83f="" class="line"> </span><span data-v-c2b1f83f="" class="line"># create a material for the BRDF; techically it's possible to</span><span data-v-c2b1f83f="" class="line"># assign BRDFs directly to nodes, but going through materials is</span><span data-v-c2b1f83f="" class="line"># preferred.</span><span data-v-c2b1f83f="" class="line">diffuseMtl=create("MtlSingleBRDF", "_overrideMtl")</span><span data-v-c2b1f83f="" class="line">diffuseMtl.set("brdf", diffuseBRDF)</span><span data-v-c2b1f83f="" class="line"> </span><span data-v-c2b1f83f="" class="line">nodes=findByType("Node") # Get all Node plugins</span><span data-v-c2b1f83f="" class="line">for node in nodes:</span><span data-v-c2b1f83f="" class="line"> node.set("material", diffuseMtl)</span></code>
Example: Creating a Slightly Rotated Rectangle Light
This example creates a rectangle light with a slightly rotated orientation.
<code data-v-c2b1f83f=""><span data-v-c2b1f83f="" class="line">from vray.utils import *</span><span data-v-c2b1f83f="" class="line">import math</span><span data-v-c2b1f83f="" class="line"></span><span data-v-c2b1f83f="" class="line">ry=math.radians(-90)</span><span data-v-c2b1f83f="" class="line">rx=math.radians(40)</span><span data-v-c2b1f83f="" class="line"></span><span data-v-c2b1f83f="" class="line"># Create a matrix to rotate around the Y axis</span><span data-v-c2b1f83f="" class="line">rotYmat=Matrix(Vector(math.cos(ry), 0, -math.sin(ry)),</span><span data-v-c2b1f83f="" class="line"> Vector(0, 1, 0),</span><span data-v-c2b1f83f="" class="line"> Vector(math.sin(ry), 0, math.cos(ry)))</span><span data-v-c2b1f83f="" class="line"></span><span data-v-c2b1f83f="" class="line"># Create a matrix to rotate around the X axis</span><span data-v-c2b1f83f="" class="line">rotXmat=Matrix(Vector(1, 0, 0),</span><span data-v-c2b1f83f="" class="line"> Vector(0, math.cos(rx), -math.sin(rx)),</span><span data-v-c2b1f83f="" class="line"> Vector(0, math.sin(rx), math.cos(rx)))</span><span data-v-c2b1f83f="" class="line"></span><span data-v-c2b1f83f="" class="line"># Compose the final matrix</span><span data-v-c2b1f83f="" class="line">rotMat=rotYmat*rotXmat</span><span data-v-c2b1f83f="" class="line"></span><span data-v-c2b1f83f="" class="line"># Create the rectangle light</span><span data-v-c2b1f83f="" class="line">light=create("LightRectangle", "newLight")</span><span data-v-c2b1f83f="" class="line">light.set('transform', Transform(rotMat, Vector(0, 2, 0)))</span></code>
Example: Changing the Color of a 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.
<code data-v-c2b1f83f=""><span data-v-c2b1f83f="" class="line">from vray.utils import *</span><span data-v-c2b1f83f="" class="line"> </span><span data-v-c2b1f83f="" class="line">l=findByType("Node") # Get all Node plugins</span><span data-v-c2b1f83f="" class="line">p=l[0].get("material") # Get the material of the first node</span><span data-v-c2b1f83f="" class="line">brdf=p.get("brdf") # Get the BRDF for the material</span><span data-v-c2b1f83f="" class="line">brdf.set("color_tex", Color(1.0, 0.0, 0.0)) # Set the BRDF color to red</span><span data-v-c2b1f83f="" class="line">t=l[0].get("transform") # Get the transformation for the first node</span><span data-v-c2b1f83f="" class="line">t.offs+=Vector(0.0, 1.0, 0.0) # Add one unit up</span><span data-v-c2b1f83f="" class="line">l[0].set("transform", t) # Set the new transformation</span></code>
Example: Converting Meshes to Subdivision Surfaces
This example shows how to converts all regular meshes in the scene to subdivision surfaces.
<code data-v-c2b1f83f=""><span data-v-c2b1f83f="" class="line">from vray.utils import *</span><span data-v-c2b1f83f="" class="line"></span><span data-v-c2b1f83f="" class="line">def smooth(geom, maxSubdivs = None, edgeLength = None):</span><span data-v-c2b1f83f="" class="line"> subdiv = create('GeomStaticSmoothedMesh', geom.name() + '@subdivGeometry') # Create a smoothed mesh plugin</span><span data-v-c2b1f83f="" class="line"> subdiv.set('mesh', geom) # Set the base geometry for the subdivision to be the original mesh plugin</span><span data-v-c2b1f83f="" class="line"> nodes = findByType('Node') # Get a list of all nodes</span><span data-v-c2b1f83f="" class="line"> </span><span data-v-c2b1f83f="" class="line"> for node in nodes:</span><span data-v-c2b1f83f="" class="line"> if node.get('geometry') == geom: # If a node references the original geometry...</span><span data-v-c2b1f83f="" class="line"> node.set('geometry', subdiv) # ...replace it with the subdivided one</span><span data-v-c2b1f83f="" class="line"> </span><span data-v-c2b1f83f="" class="line"> if maxSubdivs is not None: # Set the max. subdivs if specified</span><span data-v-c2b1f83f="" class="line"> subdiv.set('use_globals', False)</span><span data-v-c2b1f83f="" class="line"> subdiv.set('max_subdivs', maxSubdivs)</span><span data-v-c2b1f83f="" class="line"> </span><span data-v-c2b1f83f="" class="line"> if edgeLength is not None: # Set the max. edge length if specified</span><span data-v-c2b1f83f="" class="line"> subdiv.set('use_globals', False)</span><span data-v-c2b1f83f="" class="line"> subdiv.set('edge_length', edgeLength)</span><span data-v-c2b1f83f="" class="line"> </span><span data-v-c2b1f83f="" class="line">p = findByType('GeomStaticMesh') # Find all mesh plugins</span><span data-v-c2b1f83f="" class="line">for geom in p: # Replace each mesh plugin with a smoothed one</span><span data-v-c2b1f83f="" class="line"> smooth(geom)</span></code>
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.
<code data-v-c2b1f83f=""><span data-v-c2b1f83f="" class="line">from vray.utils import *</span><span data-v-c2b1f83f="" class="line">import math</span><span data-v-c2b1f83f="" class="line"> </span><span data-v-c2b1f83f="" class="line">geomNodes = findByType('Node') # Get all Node plugins</span><span data-v-c2b1f83f="" class="line">sp = geomNodes[0] # The first node</span><span data-v-c2b1f83f="" class="line">geom = sp.get('geometry') # The geometry of the first node</span><span data-v-c2b1f83f="" class="line"></span><span data-v-c2b1f83f="" class="line">r = 12 # helix radius</span><span data-v-c2b1f83f="" class="line">n = 20 # number of objects per helix turn</span><span data-v-c2b1f83f="" class="line">m = 3 # number of helix turns</span><span data-v-c2b1f83f="" class="line">h = 0.5 # height difference between objects on the helix</span><span data-v-c2b1f83f="" class="line"></span><span data-v-c2b1f83f="" class="line">for i in range(n * m):</span><span data-v-c2b1f83f="" class="line"> d = sp.duplicate('sphereNode' + str(i)) # Create a copy of the first scene node</span><span data-v-c2b1f83f="" class="line"> tr = d.get('transform') # Get the transformation matrix</span><span data-v-c2b1f83f="" class="line"> tr.offs += Vector(r * math.cos(i * 2 * 3.14159 / n), i * h, r * math.sin(i * 2 * 3.14159 / n)) # Add an offset according to the helix formula</span><span data-v-c2b1f83f="" class="line"> d.set('transform', tr) # Set the new transformation</span></code>
Example: Exporting and Changing Materials
This example exports several textures and materials and changes the material of an object.
<code data-v-c2b1f83f=""><span data-v-c2b1f83f="" class="line">from vray.utils import *</span><span data-v-c2b1f83f="" class="line"> </span><span data-v-c2b1f83f="" class="line">lambert = exportMaterial('lambert1') # Export lambert1 material</span><span data-v-c2b1f83f="" class="line">checker = exportTexture('checker1') # Export checker1 texture</span><span data-v-c2b1f83f="" class="line">cloth = exportTexture('cloth1') # Export cloth1 texture</span><span data-v-c2b1f83f="" class="line"></span><span data-v-c2b1f83f="" class="line">brdf = lambert.get('brdf') # Get the 'lambert1@material' plugin</span><span data-v-c2b1f83f="" class="line">brdf.set('transparency_tex', checker.output('color')) # Set the transparency_tex parameter of the brdf</span><span data-v-c2b1f83f="" class="line">brdf.set('color_tex', cloth) # Set the color_tex parameter of the brdf</span><span data-v-c2b1f83f="" class="line"> </span><span data-v-c2b1f83f="" class="line">planeNode = Plugin('pPlaneShape1@node') # Get the plane node</span><span data-v-c2b1f83f="" class="line">planeNode.set('material', lambert) # Set the material of the plane</span></code>
Example: Combining the Contents of Several Scenes
This example adds the contents of several scenes and uses some of the newly created plugins.
<code data-v-c2b1f83f=""><span data-v-c2b1f83f="" class="line">from vray.utils import *</span><span data-v-c2b1f83f="" class="line"></span><span data-v-c2b1f83f="" class="line">addSceneContent('blinn.vrscene', 'basic_') # Create all plugins in this scene file and prepend 'basic_' to the names of all plugins</span><span data-v-c2b1f83f="" class="line">addSceneContent('vraymtl.vrscene') # Create all plugins in this scene file and use the original names</span><span data-v-c2b1f83f="" class="line"></span><span data-v-c2b1f83f="" class="line">blinn = Plugin('basic_blinn1@material') # Get the blinn material from the first added scene</span><span data-v-c2b1f83f="" class="line">vraymtl = Plugin('VRayMtl1@material') # Get the V-Ray material from the second added scene</span><span data-v-c2b1f83f="" class="line"></span><span data-v-c2b1f83f="" class="line">nodes = findByType('Node') # Find all nodes in the scene</span><span data-v-c2b1f83f="" class="line"></span><span data-v-c2b1f83f="" class="line"># Change the materials of some of the nodes</span><span data-v-c2b1f83f="" class="line">nodes[0].set('material', blinn)</span><span data-v-c2b1f83f="" class="line">nodes[1].set('material', vraymtl)</span></code>
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:
<code data-v-c2b1f83f=""><span data-v-c2b1f83f="" class="line">from vray.utils import *</span><span data-v-c2b1f83f="" class="line"></span><span data-v-c2b1f83f="" class="line">lightLinker = findByType('SettingsLightLinker')[0] # Get the SettingsLightLinker plugin</span><span data-v-c2b1f83f="" class="line">directLight = findByType('MayaLightDirect')[0] # Get the first directional light</span><span data-v-c2b1f83f="" class="line">spotLight = findByType('LightSpot')[0] # Get the first spot light</span><span data-v-c2b1f83f="" class="line">nodes = findByType('Node') # Get all geometry nodes in the scene</span><span data-v-c2b1f83f="" class="line"></span><span data-v-c2b1f83f="" class="line">param = [[directLight, nodes[0], nodes[1]], [spotLight, nodes[2]]] # Just create a list of lists</span><span data-v-c2b1f83f="" class="line">lightLinker.set("ignored_lights", param)</span></code>
Example: Connect a Plugin Output
This example shows how to get a specific output from a plugin and use it as an input to another plugin's parameter.
First, we assume we know the name of an object in the scene. We get its material, then the material's BRDF, then the BRDF's diffuse texture. We create a TexAColorOp texture plugin, where we multiply the BRDF's diffuse texture by another color. The second color we multiply by could also be another texture reference. Finally, we use the 'product' output of TexAColorOP as the diffuse input of the BRDF. Any plugin's specific output can be used in the same way.
<code data-v-c2b1f83f=""><span data-v-c2b1f83f="" class="line">from vray.utils import *</span><span data-v-c2b1f83f="" class="line"></span><span data-v-c2b1f83f="" class="line"># Assuming an object pPlaneShape1@node has a VRayMtl assigned</span><span data-v-c2b1f83f="" class="line"># Get the material's diffuse texture and pass it through a TexAColorOp</span><span data-v-c2b1f83f="" class="line"># Create a TexAColorOp plugin</span><span data-v-c2b1f83f="" class="line"># Multiply the texture by a color inside TexAColorOp</span><span data-v-c2b1f83f="" class="line"># Get the 'product' output from TexAColorOp and use it as the diffuse input in the VRayMtl</span><span data-v-c2b1f83f="" class="line"></span><span data-v-c2b1f83f="" class="line">node = findByName('pPlaneShape1@node')[0] # Find the node by name</span><span data-v-c2b1f83f="" class="line">node_mtl = node.get('material') # Get the node's material</span><span data-v-c2b1f83f="" class="line">node_brdf = node_mtl.get('brdf') # Get the material's brdf to reach the BRDFVRayMtl plugin</span><span data-v-c2b1f83f="" class="line">diffuseTex = node_brdf.get('diffuse') # Get the diffuse texture of BRDFVRayMtl</span><span data-v-c2b1f83f="" class="line"></span><span data-v-c2b1f83f="" class="line">colorOp = create('TexAColorOp', 'TexAColorOp1') # Create a TexAColorOp texture</span><span data-v-c2b1f83f="" class="line">colorOp.set('color_a', diffuseTex) # Set the VRayMtl's diffuse texture as color_a</span><span data-v-c2b1f83f="" class="line">colorOp.set('color_b', Color(1.0, 0.1, 0.1)) # Set a Color() as color_b</span><span data-v-c2b1f83f="" class="line"></span><span data-v-c2b1f83f="" class="line">node_brdf.set('diffuse', colorOp.output('product')) # Set the 'product' output of TexAColorOp as the diffuse input of BRDFVRayMtl</span><span data-v-c2b1f83f="" class="line"></span><span data-v-c2b1f83f="" class="line"># Similarly, we can get the 'sum' or any other output</span><span data-v-c2b1f83f="" class="line"># node_brdf.set('diffuse', colorOp.output('sum'))</span></code>