# quick and dirty python script to change/add vray Object id's

**URL:** <https://forums.chaos.com/t/quick-and-dirty-python-script-to-change-add-vray-object-ids/25732>\
**Category:** General\
**Created:** [October 19, 2010, 11:21am UTC](https://forums.chaos.com/t/quick-and-dirty-python-script-to-change-add-vray-object-ids/25732 "2010-10-19T11:21:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tinuz](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/tinuz/32/42768_2.png) [@tinuz](https://forums.chaos.com/u/tinuz)\
**Post date:** [October 19, 2010, 11:21am UTC](https://forums.chaos.com/t/quick-and-dirty-python-script-to-change-add-vray-object-ids/25732/1 "2010-10-19T11:21:05Z")

</div>

Hi guys,

I’ve written a small python script to manage vray object ID attrs..  
I’m not a good programmer so it’s probably full of things that can be improved, so feel free to edit as you wish.. I will improve it when I have time or feel the need but I cannot give (alot) support.. but don’t hesitate to post suggestions or wishes, can’t promise anything though, hope you’ll understand..  
I only have maya 2011 so don’t know if it works in other versions..

NOTE:

- don’t change your selection and edit a number, because it will loop through the current selection, so if you change selection rerun the script.

planned todo’s:

- button or field to assign same id to selected objects at once.  
- ability to give attr to procedure so you can use this for other Attr’s too.  
- automatically make needed multi matte render elements..  
hope it’s useful for someone!  
[vrayChangeAttr.py.zip](https://forums.chaos.com/uploads/short-url/ktYMyOfn4qC3hU4dX44dn8fxdv6.zip) (1.47 KB)

---

<div class="post-metadata">

**Author:** ![vlado](https://avatars.discourse-cdn.com/v4/letter/v/779978/32.png) [@vlado](https://forums.chaos.com/u/vlado)\
**Post date:** [October 19, 2010, 11:51am UTC](https://forums.chaos.com/t/quick-and-dirty-python-script-to-change-add-vray-object-ids/25732/2 "2010-10-19T11:51:02Z")

</div>

Cool, thanks for sharing 🙂

Best regards,  
Vlado

---

<div class="post-metadata">

**Author:** ![aweidenhammer](https://avatars.discourse-cdn.com/v4/letter/a/6de8d8/32.png) [@aweidenhammer](https://forums.chaos.com/u/aweidenhammer)\
**Post date:** [October 20, 2010, 4:29pm UTC](https://forums.chaos.com/t/quick-and-dirty-python-script-to-change-add-vray-object-ids/25732/3 "2010-10-20T16:29:21Z")

</div>

I keep getting a global name ‘cmds’ is not defined. I tried importing maya as cmds, and maya.cmds as cmds. I haven’t fiddled much with python, so I may be doing something wrong. I’m also on 2010, so perhaps it is a pymel version thing.

Looking at the script tho, it looks like they are all mel commands wrapped in a cmds.XXX Why not just release it as mel?

---

<div class="post-metadata">

**Author:** ![aweidenhammer](https://avatars.discourse-cdn.com/v4/letter/a/6de8d8/32.png) [@aweidenhammer](https://forums.chaos.com/u/aweidenhammer)\
**Post date:** [October 20, 2010, 4:30pm UTC](https://forums.chaos.com/t/quick-and-dirty-python-script-to-change-add-vray-object-ids/25732/4 "2010-10-20T16:30:20Z")

</div>

btw, this sounds great. Would love to get it working. thanks for the effort!

---

<div class="post-metadata">

**Author:** ![tinuz](https://dub1.discourse-cdn.com/chaosprd/user_avatar/forums.chaos.com/tinuz/32/42768_2.png) [@tinuz](https://forums.chaos.com/u/tinuz)\
**Post date:** [October 21, 2010, 8:58am UTC](https://forums.chaos.com/t/quick-and-dirty-python-script-to-change-add-vray-object-ids/25732/5 "2010-10-21T08:58:28Z")

</div>

> [@simmsimaging](#):
>
> I keep getting a global name ‘cmds’ is not defined. I tried importing maya as cmds, and maya.cmds as cmds. I haven’t fiddled much with python, so I may be doing something wrong. I’m also on 2010, so perhaps it is a pymel version thing.
> 
> Looking at the script tho, it looks like they are all mel commands wrapped in a cmds.XXX Why not just release it as mel?

so sorry.. I have these procedures in a larger python file so I forgot to include these lines for you, just put them above the first def at the beginning of the line:

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

_def changeVrayAttr():_

well I’m trying to stay off the mel, I like python much better, and as you can see I can us mel in python too 😜

---

<div class="post-metadata">

**Author:** ![aweidenhammer](https://avatars.discourse-cdn.com/v4/letter/a/6de8d8/32.png) [@aweidenhammer](https://forums.chaos.com/u/aweidenhammer)\
**Post date:** [October 21, 2010, 2:32pm UTC](https://forums.chaos.com/t/quick-and-dirty-python-script-to-change-add-vray-object-ids/25732/6 "2010-10-21T14:32:21Z")

</div>

thanks for the update. I’ll give it a try today.

Andrew
