VRay Multi Matte quick apply

Hi guys I was just flicking through the forums so see if there is a script of some sort to
apply Multi matte and Object IDs to selected groups of objects all at once and specify what IDs they should have?
I have a huge scene with quite a few objects and need to make this process less of a headache

thanks in advance

-A

Hi,
My DeeX VRay Arsenal have this function :wink: .
The tool generate ID based on the name of the selection.

If you wan create mattes, there is a function to create mattes on the fly (and you can export all).

As ill be trying to do this at work i dont think the studio will purchase you tool for us lol
But thanks though

Heya

I’ve mocked up a while ago a script that could help you, however this one is for materials…

Select all the materials you want to have custom ID for.

Use in python


 import maya.cmds as cmds
 selectedM = cmds.ls(sl=1)
    try:
        for selectedMat in selectedM:
            mel.eval('vray addAttributesFromGroup ' + selectedMat + ' vray_material_id 1')
    except:
        pass
    try:      
        for mats in selectedM:
            x = selectedM.index(mats)
            cmds.setAttr('%s.%s'%(mats,'vrayMaterialId') ,x + 1)
    except:
        pass            

edit:
And this is quick mock up for geometry… see if it works.


    import maya.cmds as cmds
    selectedO = cmds.ls(sl=1)
    try:
        for selectedOBJ in selectedO:
            mel eval('vray addAttributesFromGroup '+ selectedOBJ=' vray_objectID 1')         
    except:
        pass
    try:      
        for OBJ in selectedO:
            x = selectedO.index(OBJ)
            cmds.setAttr('%s.%s'%(OBJ,'vrayObjectID') ,x + 1)
    except:
        pass        

Thanks DADAL, but i cant get it to run I get an error

Try this one in python. Just select ur objects 1st.


import maya.cmds as cmds
import maya.mel as mel

try: 
    relative = cmds.listRelatives(s=1)
    for selectedOBJ in relative:
        mel.eval('vray addAttributesFromGroup ' + selectedOBJ + ' vray_objectID 1')     

except:
    pass

try:     
    relativeO = cmds.listRelatives(s=1) 
    for OBJ in relativeO:
        x = relativeO.index(OBJ)
        cmds.setAttr('%s.%s'%(OBJ,'vrayObjectID') ,x)
except:
    pass

Ok here it goes. It should work with anything selected so watch out what you are selecting !

this is awesome! is there a string that you could add that specifies what ID the object gets?

Thanks again man this will really help me set up my Ldev scenes!!

ID have to script in UI and stuff. How would you want to control it? Select 1 OBJ and type in Number? basically a shortcut rather than Attribute editor or what?

Thanks, bye.

Umm something like select like either one object and input a number or shift select 3 objects and then input the 3 different numbers?
or is that a huge ask?
whats ever is easier!

Thanks again!

Well if you want 1 object then just select 1 object and keep attr editor open with slided to the bottom. You can just type the ID there. Then everytime you click on new object the UI should stay and you can type other numbers… regarding multi selection humh…maybe I’ll see what I can do ( could be fun exercise) but dont expect it to happen too quick :S.

Thanks, bye.

Thank You! for this script very useful … have you had the chance to play with some kind of UI yet?