Hi Johan, I have written a tool at work that creates material IDs, and multi-mattes of every shader in the scene. Are you on the latest version of Vray because we have no problems setting the attribute immediately afterwards. Maybe there is an issue with older versions of vray in maya.
I am using Maya 2012 and VRay 2.25.01.22904 Below is an example that I have successfully run on my end. You will just need to create a vray material named, 'VRayMtl1' import maya.cmds as mc import maya.mel as mm shaderName = 'VRayMtl1' ID = 1001 mm.eval('vray addAttributesFromGroup %s vray_material_id 1;' % shaderName) mc.setAttr (('%s.vrayMaterialId' % shaderName), ID) On Monday, 28 October 2013 12:38:42 UTC-4, shapeofmotion wrote: > > Thank you, > > But I would like to set the id after creation. > like so: > > import maya.cmds as cmds > import maya.mel as mel > > # add vray material ID > mel.eval("vray addAttributesFromGroup VRayMtl1 vray_material_id 1") > cmds.setAttr('VRayMtl1.vrayMaterialId', 2) > # Error: RuntimeError: file <maya console> > # line 1: setAttr: No object matches name: VRayMtl1.vrayMaterialId > > It seems like that the command to add the vray material attribute is not > done before maya tries to set the attr id, and it cant find the attr. > I thought that the commands were executed in turn, can I add callback or > can I somehow make sure that the attr is allowed to be created before we > move on ? > > Thanks, > Johan > > > -- 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 python_inside_maya+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/5a282fff-7cb7-4673-bac4-f1477f382827%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.