All good, I need to fix up something here for objectID's anyway.
I'm a big fibber. I used evalDeferred (thanks to a far more savvy TD
recommending it):
import maya.cmds as cmds
import maya.mel as mel
myObj = cmds.ls (sl=True, dag=True, type='shape')
myObj = myObj[0]
idNumber = 5
for obj in myObj:
mel.eval('vray addAttributesFromGroup ' + myObj + ' vray_objectID 1')
cmds.evalDeferred(lambda object=myObj,object_id=idNumber:
cmds.setAttr(object + '.vrayObjectID', idNumber))
I used to loop over all the selected objects adding incremental ID's.
Divide by three then create that many multimattes render elements. As long
as I sorted the initial list properly (and the target's object count did
not change), I could automate matte creation in a crude fashion. Same for
Material ID's (though that tends to be tricker because of
double-sided/blend material use and the like).
On Wed, Oct 30, 2013 at 1:19 AM, johan Borgström <[email protected]>wrote:
> Hi Christopher!
>
> Thanks for your answer, I tried to use partial but got the same error, so
> If you can show how you did it that would be great.
>
> I looked through the echoed history of what happens when I manually add
> the vray material attr and found some lines of code that looked
> interesting. If I add the line "vrayAddAttr VRayMtl1 vrayMaterialId" I was
> able to set the material id without the error I described earlier.
> Hmmm, not clear what that line does ... but somehow it make Maya aware
> that the attr exists :)
>
> (Btw It looks like the line that contains "vrayAddAttr VRayMtl1
> vrayColorId" is not necessary)
>
> Br,
> johan
>
>
> mat = 'VRayMtl1'
> id = 4
> mel.eval('vray addAttributesFromGroup {0} vray_material_id 1;'.format(mat
> ))
> #mel.eval('vrayAddAttr {0} vrayColorId;'.format(mat))
> mel.eval('vrayAddAttr {0} vrayMaterialId;'.format(mat))
> cmds.setAttr (('{0}.vrayMaterialId'.format(mat)), id)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/4c095ff9-74e9-492a-862e-606cf0a85fd6%40googlegroups.com
> .
>
> For more options, visit https://groups.google.com/groups/opt_out.
>
--
----
Christopher Stewart
Vancouver, BC
3D TD | VFX IT
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CAGnq0iBTtBLhfaaXahfT682ZbX2auDQ40iykXqw%2BP1bk2EBdCA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.