This page provides information on using MAXScript with V-Ray.

Overview


In 3ds Max, assuming that your current renderer is set to V-Ray, you can refer to it from MAXScript using the renderers structure:

vr=renderers.current

V_Ray_5:V_Ray_5

 


For more information on controlling the V-Ray VFB with MaxScript, please refer to Controlling the Old VFB Programmatically and Controlling the New VFB Programmatically pages.

Here are some guidelines for using MaxScript:

  • Arguments listed as Boolean can only receive true/false values. These options turn a feature on (true) or off (false).
  • Remember that float values include a decimal while integers do not. This means that integers can be used when a float is required, but float values cannot be used where integers are required.
  • String values must be enclosed in double quotes.
  • Available values from enumerated lists are presented with a pipe (|) separator. For example, 0 | 1 | 2 means the argument value can only be a 0, 1, or 2. String values of this argument type are input with quote marks. For example, #setregion "reset"
  • Many commands will return the current values for the parameter when used without arguments. This feature has been enabled for all commands for which it makes sense to do so.


Renderer Properties


Assuming that the variable vr holds an instance of the V-Ray renderer, you can work with the renderer settings as with any other MAXScript object:

showproperties vr

 .imageSampler_type : integer

.fixedRate_subdivs : integer

.fixedRate_rand : boolean

...............

...............

...............

.options_maxDepth : integer

.options_maps : boolean

.options_filterMaps : boolean

.output_on : boolean

.output_width : integer

.output_height : integer

.output_fileOnly : boolean

.output_saveFile : boolean

.output_fileName : string

.output_saveRawFile : boolean

.output_rawFileName : string

false


Accessing the parameters is fairly easy, for example:

vr.gi_on=true
true


Renderer Methods  


The following methods can be used for saving/loading irradiance and photon maps (assuming that vr holds an instance of V-Ray):

Renderer method Description
vr.saveIrradianceMap <filename> Saves the current irradiance map to the given file.
vr.saveLightCache <filename> Saves the current light cache to the given file.
vr.loadIrradianceMap <filename> Loads the irradiance map from the given file.
vr.clearIrradianceMap()clears the irradiance map that is currently in memory
vr.clearLightCache()Clears the light cache that is currently in memory.
vr.showLastVFB()Shows the V-Ray VFB window with last rendered image.


Global Functions


Additionally, the following MAXScript functions are globally available:

Global function Description
renderers.current = VRay()Sets V-Ray as the production renderer by resetting any settings that might have been adjusted in Render Setup. A new instance of the renderer is created and used.
renderers.current = VRayRT()Sets V-Ray GPU as the production renderer by resetting any settings that might have been adjusted in Render Setup. A new instance of the renderer is created and used.

vrayExportVRScene <filename>

[separateFiles: true|false]

[exportView: true|false]

[exportLights: true|false]

[exportGeometry: true|false]

[exportNodes: true|false]

[exportMaterials: true|false]

[exportTextures: true|false]

[exportBitmaps: true|false]

[exportSelectionOnly: true|false]

[exportSettings: true|false]

[incrBaseFrame: true|false]

[prefix: <prefix string>]

[startFrame: <startFrame>]

[endFrame: <endFrame>]

[stripPaths: true|false]


Directly export the current 3ds Max scene into a .vrscene file from the current viewport.

If the separateFiles option is set to true, the scene components will be split in different files depending on their type (view transformation, lights, mesh geometry, node transformations, materials, textures and bitmaps).

If the prefix keyword is specified, the prefix string will be added in front of all plugin names in the resulting .vrscene file.

If the startFrame and endFrame options are specified, an animated .vrscene file is exported for the specified frames.

If the stripPaths option is set to true, then any assets (bitmaps, irradiance maps, IES files etc.) are only written with their file names, without the path.

NOTE: The exporter takes the render settings from V-Ray GPU, thus it must be the current production renderer, otherwise default rendering settings will be exported.

NOTE 2: Currently the .vrscene export follows the settings in the V-Ray GPU renderer for export of proxies, X-Ref scenes and containers, particle systems and displacement.



vraySceneImport <vrscene file> <folder>

[geometry:true|false]

[cameras:true|false]

[lights:true|false]


<vrscene file> is the .vrscene file to be imported in 3ds max.

<folder> is the existing folder path where .tx files will be generated from the baked pixel data in the imported .vrscene file.

doVRayObjectProperties()Brings up the V-Ray Object Properties dialogue.
doVRayMeshExport()Brings up the V-Ray Mesh Export dialogue.

vrayMeshExport

[meshFile: "<mesh file>"]


[autoCreateProxies: true|false]

[exportMultiple: true|false]

[animation: on|off]

[animationRange: #scene|#explicit]

[animationStart: <integer>]

[animationEnd: <integer>]

[animationRedrawViews: true|false]

[minPreviewFaces: <integer>]

[maxPreviewFaces: <integer>]

[previewFacesPercentage: <integer>]

[previewMesh: <preview node>]

[nodes: <object/array of objects/ objectset>]

[proxyName: "<string>"]

[createMultiMtl: true|false]

[condenseMultiMtl: true|false]

[facesPerVoxel: <integer>]

[oneVoxelPerMesh: true|false]

[exportPointClouds: true|false]

[pointSize: <float>]

[previewType: <string>]

 

Exports a .vrmesh file without showing a dialog. Returns an array of newly created VRayProxy object(s), if any.

<mesh file>  is the name of the desired .vrmesh file. If the name does not contain a path, the default 3ds Max mesh path is used. If the name does not contain an extension, a .vrmesh extension is automatically appended.

If the autoCreateProxies option is not specified, by default the meshes are just exported, no proxies are created in the scene.

If the exportMultiple option is not specified, the meshes are exported to multiple files by default.

If the animation option is set to on, an animated proxy file is created.

In that case, the range of the animation is determined by the animationRange option - if set to  #explicit, then the frame range for the export is specified by the animationStart and animationEnd options (in frames), otherwise the current scene animation range is used.  

If the animationRedrawViews option is set to  true,  then the viewports will be updated during the animation export process.

If the minPreviewFaces parameter is specified, then the exported .vrmesh file will contain a preview with the specified minimum number of triangles.

If the maxPreviewFaces parameter is specified, then the exported .vrmesh file will contain a preview with the specified maximum of triangles, otherwise a default value of 10000 triangles is used.

 If the previewFacesPercentage parameter is specified, then that percentage of the total faces are shown in the preview mesh. 

previewType can accept three strings as values: "clustering", "combined" and "face_sampling" (which in that order correspond to "Vertex clustering", "Refined clustering" and "Face skipping" from the UI).

Note: The previewMesh option is only valid when exporting to a single .vrmesh file (i.e. exportMultiple is false). The proxyName option is only valid when autoCreateProxies is true.

vrayMeshImport 

[proxy: <proxy mesh object(s)>]

[explicitNormals: true|false]

[weldVertices: true|false]

Imports the geometry of the selected VRayProxy object(s) as an editable mesh.

<proxy mesh object(s)> is a single VRayProxy object, an array of VRayProxy objects or an ObjectSet (for example $geometry). If this option is not specified, VRayProxy object(s) from the current selection are imported as mesh(es).

registerVRayMenus()Registers the various V-Ray components (lights, cameras, geometry objects, modifiers etc.) into the 3ds Max Create, Modifiers etc. menus. This function is useful if the 3ds Max menu system is reset and the menu associations are lost. You can also call this function directly from the V-Ray toolbar.
unregisterVRayMenus()Removes V-Ray specific items from the 3dsMax standard menus.
updateVRayMenus()Refreshes all V-Ray specific items in the 3ds Max standard menus.
setVRaySilentMode()Disables any V-Ray dialogues that may appear when loading a scene (i.e. notification for differences with older versions, etc.).
vrayEditDRSettings()Opens the dialogue for editing the V-Ray DR settings.
vrayAddTraceSets <node> Adds and returns a new V-Ray trace sets object for the specified node (or just returns it, if there is one already). Use showproperties on the returned object to see what properties are available (the reflection and refraction trace sets).

vrayAddTraceSets <node> set:<traceset>

[b = vrayGetTraceSets $Sphere
vrayAddTraceSets $Teapot set:b]

Adds and returns the trace set object specified in the set argument to the specified node.

The example function gets the information for reflection and refraction excludes from the V-Ray Properties of the Sphere and sets the same for the Teapot.

vrayRemoveTraceSets <node> Removes the V-Ray trace sets object for the specified node.
vrayGetTraceSets <node> Returns the V-Ray trace sets object for the specified node, or undefined if there isn't one.
vrayVersion()Returns an array of two elements with the current version of V-Ray and the build number. The build number is only defined for nightly builds and may be an empty string for official builds.
vrayShowMsgLogWindow()Shows the V-Ray messages window.
vrayCloseMsgLogWindow()Closes the V-Ray messages window.
vrayUpdateCRTEnvVars()Updates the CRT environment variables. This function can be called to update the environment after setting or changing environment variables.


V-Ray IPR Functions


Additional MAXScript functions are available for Interactive Production Rendering.

V-Ray IPR functionDescription
vrayIsRenderingIPR()

Returns 1 if an IPR render is active in the V-Ray Frame Buffer.
Returns 2 if an IPR render is active in any 3ds Max viewport.
Returns 0 if an IPR render is not active.

vrayStartIPR()Starts interactive production rendering for either V-Ray or V-Ray GPU render enegine.
vrayUpdateIPR()Refreshes interactive rendering.

vrayStopIPR()

Stops the current interactive rendering.

Image Completed Callback

When the rendering is complete, V-Ray will try to call a MAXScript function called vrayIPRImageComplete. To perform an action when the rendering is finished, you can define this function yourself. For example, the following code prints a message when the rendering is complete:

global vrayIPRImageComplete

fn vrayIPRImageComplete = (
		print "IPR Image completed "
)



V-Ray GPU Functions


Additional MAXScript functions are added by the V-Ray GPU renderer.

V-Ray GPU functionDescription
vrayGetRTBitmap()Returns the contents of current V-Ray GPU IPR window as a bitmap, or undefined if V-Ray GPU IPR is not started.

With V-Ray Next GPU selected as production renderer all script specific to this engine can be listed by executing:

vr = renderers.current

V_Ray_GPU_Next__update_1_1:V_Ray_GPU_Next__update_1_1

showproperties vr

Some of the settings reside under V_Ray_settings. In order to list those properties, you can use the following commands:

showproperties vr.V_Ray_settings

Some parameters listed directly under the showproperties vr for V-Ray GPU are read-only by design. The respective property with an editable value for this parameter may reside under vr.V_Ray_settings.