[Closed] vray3 trace sets, maxscript help
hi im having trouble writing a maxscript :banghead: using vray 3 and its new trace sets,
Looking at the vray 3 maxscript commands i have found:
vrayAddTraceSets <node>
vrayRemoveTraceSets <node>
vrayGetTraceSets <node>
http://docs.chaosgroup.com/display/VRAY3/MaxScript
What im trying to do is write two scripts but i dont really understand how to do this :
Script one
Select the 鈥渢arget object鈥? (object you want reflections/refractions to be excluded from) and add all scene objects into the exclude reflection/ refraction list.
The exclude reflection/ refraction sets can be found in the vray properties
Script two
Select all objects you want to be reflected/ refracted into the 鈥渢arget object鈥? Then select last the 鈥渢arget object鈥? Run this script and it would remove the selected objects from the exclude reflection refraction list. So this objects may reflect in the target object.
Thanks in advance
Ravi
Ok getting closer, i found this on chaos group forum, about creating trace sets with maxscript.
But cant seem to get this script to work? any ideas?
If you read my post above im after two scripts, i think its all in this script but i cant seem to execute it. :banghead:
Thanks in advance
-- V-Ray Trace Sets operations functions
-------------------------------------------------------------------------------
fn vrayTraceSetsAddNodes target nodes = (
-- ensure we have trace sets on the target object
local traceSets = vrayGetTraceSets target
if (traceSets == undefined) do (traceSets = vrayAddTraceSets target)
if ((nodes != undefined) and (isproperty nodes #count) and (nodes.count > 0)) do (
for nd in nodes do (
if (nd != target) do (
local nodeTraceSets = vrayGetTraceSets nd
local nodeTraceSetsNodes = #()
if (nodeTraceSets != undefined) do (nodeTraceSetsNodes = nodeTraceSets.reflect_exclude as Array)
if (findItem nodeTraceSetsNodes target == 0) do (
append traceSets.reflect_exclude nd
)
nodeTraceSetsNodes = #()
if (nodeTraceSets != undefined) do (nodeTraceSetsNodes = nodeTraceSets.refract_exclude as Array)
if (findItem nodeTraceSetsNodes target == 0) do (
append traceSets.refract_exclude nd
)
)
)
-- exclude repeating objects, hope it's faster than adding with appendIfUnique
traceSets.reflect_exclude = makeUniqueArray (traceSets.reflect_exclude as array)
traceSets.refract_exclude = makeUniqueArray (traceSets.refract_exclude as array)
)
)
fn vrayTraceSetsRemoveNodes target nodes = (
-- ensure we have trace sets on the target object
local traceSets = vrayGetTraceSets target
if (traceSets == undefined) do (traceSets = vrayAddTraceSets target)
if ((nodes != undefined) and (isproperty nodes #count) and (nodes.count > 0)) do (
local currentreflectNodes = traceSets.reflect_exclude as Array
local currentrefractNodes = traceSets.refract_exclude as Array
for nd in nodes do (
local index = findItem currentreflectNodes nd
if (index > 0) do (deleteItem currentreflectNodes index)
index = findItem currentrefractNodes nd
if (index > 0) do (deleteItem currentrefractNodes index)
)
traceSets.reflect_exclude = currentreflectNodes
traceSets.refract_exclude = currentrefractNodes
)
)
-- vrayTraceSetsAdd: operates on current selection so it can be assigned to button/menuItem.
-- The last object in the selections is considered target object and the others before it are
-- added in both reflection/refraction exclude lists. If only one object selected then it's target
-- and all other objects in the scene are added to the exclude lists. If there are already objects
-- in the lists they remain also.
fn vrayTraceSetsAdd = (
local nodesList = #()
for nd in $selection do (
if (superClassOf nd == GeometryClass) do (
append nodesList nd
)
)
local targetNode = undefined
if (nodesList.count > 0) do (targetNode = nodesList[nodesList.count])
if (targetNode != undefined) do (
if ($selection.count == 1) then (
vrayTraceSetsAddNodes targetNode $geometry
)
else (
vrayTraceSetsAddNodes targetNode nodesList
)
)
)
-- vrayTraceSetsRemove: operates on current selection so it can be assigned to button/menuItem.
-- The last object in the selections is considered target object and the others before it are
-- removed from both reflection/refraction exclude lists. If only one object selected then it's target
-- and all other objects in the scene are removed to the exclude lists.
fn vrayTraceSetsRemove = (
local nodesList = #()
for nd in $selection do (
if (superClassOf nd == GeometryClass) do (
append nodesList nd
)
)
local targetNode = undefined
if (nodesList.count > 0) do (targetNode = nodesList[nodesList.count])
if (targetNode != undefined) do (
if ($selection.count == 1) then (
vrayTraceSetsRemoveNodes targetNode $geometry
)
else (
vrayTraceSetsRemoveNodes targetNode nodesList
)
)
)