# VRay Multi Matte quick apply

**URL:** <https://forums.chaos.com/t/vray-multi-matte-quick-apply/45503>\
**Category:** Tutorials, Tips & Tricks\
**Created:** [June 16, 2013, 11:53pm UTC](https://forums.chaos.com/t/vray-multi-matte-quick-apply/45503 "2013-06-16T23:53:25Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![4th-Child](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/4th-child/32/4078_2.png) [@4th-Child](https://forums.chaos.com/u/4th-Child)\
**Post date:** [June 16, 2013, 11:53pm UTC](https://forums.chaos.com/t/vray-multi-matte-quick-apply/45503/1 "2013-06-16T23:53:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bigbossfr](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/bigbossfr/32/50480_2.png) [@bigbossfr](https://forums.chaos.com/u/bigbossfr)\
**Post date:** [June 17, 2013, 8:57am UTC](https://forums.chaos.com/t/vray-multi-matte-quick-apply/45503/2 "2013-06-17T08:57:30Z")

</div>

> [@4th-Child](#):
>
> 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 😉 .  
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).

---

<div class="post-metadata">

**Author:** ![4th-Child](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/4th-child/32/4078_2.png) [@4th-Child](https://forums.chaos.com/u/4th-Child)\
**Post date:** [June 17, 2013, 1:19pm UTC](https://forums.chaos.com/t/vray-multi-matte-quick-apply/45503/3 "2013-06-17T13:19:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Dariusz\_Makowski\_Dadal](https://avatars.discourse-cdn.com/v4/letter/d/c4cdca/32.png) [@Dariusz\_Makowski\_Dadal](https://forums.chaos.com/u/Dariusz_Makowski_Dadal)\
**Post date:** [June 17, 2013, 2:16pm UTC](https://forums.chaos.com/t/vray-multi-matte-quick-apply/45503/4 "2013-06-17T14:16:31Z")

</div>

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

```auto

 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.

```auto

    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        

```

---

<div class="post-metadata">

**Author:** ![4th-Child](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/4th-child/32/4078_2.png) [@4th-Child](https://forums.chaos.com/u/4th-Child)\
**Post date:** [June 18, 2013, 12:40pm UTC](https://forums.chaos.com/t/vray-multi-matte-quick-apply/45503/5 "2013-06-18T12:40:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Dariusz\_Makowski\_Dadal](https://avatars.discourse-cdn.com/v4/letter/d/c4cdca/32.png) [@Dariusz\_Makowski\_Dadal](https://forums.chaos.com/u/Dariusz_Makowski_Dadal)\
**Post date:** [June 18, 2013, 12:45pm UTC](https://forums.chaos.com/t/vray-multi-matte-quick-apply/45503/6 "2013-06-18T12:45:12Z")

</div>

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

```auto

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 !

---

<div class="post-metadata">

**Author:** ![4th-Child](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/4th-child/32/4078_2.png) [@4th-Child](https://forums.chaos.com/u/4th-Child)\
**Post date:** [June 18, 2013, 1:27pm UTC](https://forums.chaos.com/t/vray-multi-matte-quick-apply/45503/7 "2013-06-18T13:27:21Z")

</div>

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!!

---

<div class="post-metadata">

**Author:** ![Dariusz\_Makowski\_Dadal](https://avatars.discourse-cdn.com/v4/letter/d/c4cdca/32.png) [@Dariusz\_Makowski\_Dadal](https://forums.chaos.com/u/Dariusz_Makowski_Dadal)\
**Post date:** [June 18, 2013, 1:41pm UTC](https://forums.chaos.com/t/vray-multi-matte-quick-apply/45503/8 "2013-06-18T13:41:23Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![4th-Child](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/4th-child/32/4078_2.png) [@4th-Child](https://forums.chaos.com/u/4th-Child)\
**Post date:** [June 18, 2013, 2:05pm UTC](https://forums.chaos.com/t/vray-multi-matte-quick-apply/45503/9 "2013-06-18T14:05:11Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Dariusz\_Makowski\_Dadal](https://avatars.discourse-cdn.com/v4/letter/d/c4cdca/32.png) [@Dariusz\_Makowski\_Dadal](https://forums.chaos.com/u/Dariusz_Makowski_Dadal)\
**Post date:** [June 18, 2013, 2:57pm UTC](https://forums.chaos.com/t/vray-multi-matte-quick-apply/45503/10 "2013-06-18T14:57:44Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![hsz](https://avatars.discourse-cdn.com/v4/letter/h/e495f1/32.png) [@hsz](https://forums.chaos.com/u/hsz)\
**Post date:** [May 9, 2015, 12:09am UTC](https://forums.chaos.com/t/vray-multi-matte-quick-apply/45503/11 "2015-05-09T00:09:57Z")

</div>

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