Hey guys!

I am starting working in maya and python and here is the first problem I 
faced:

I cannot access a newly created aiCustomAOV of my shading group. The print 
gives me zero as a number of AOVs of the shading group (see last line in 
the code).

If I divide the code to two parts (create an AOV and query the attribute of 
shading group) and run them separately I get the result, but I think it is 
not the proper way of doing that. Right?
Usually, when I create a custom AOV from Render settings it automatically 
adds the AOV to a shading group list of aiCustomAOVS.
It seems that there is an initialization issue. How to overcome it?

Here is the code:

# check whether the aiAOV_Default_Color exists
if not cmds.objExists('aiAOV_Default_Color'):
    customAOV = cmds.createNode('aiAOV',n='aiAOV_Default_Color', 
skipSelect=True)
    cmds.setAttr(customAOV+'.name','Default_Color',type='string')
    
cmds.connectAttr(customAOV+'.message','defaultArnoldRenderOptions.aovList',force=1)
    
cmds.connectAttr('defaultArnoldDriver.message',customAOV+'.outputs[0].driver', 
force=1)
    
cmds.connectAttr('defaultArnoldFilter.message',customAOV+'.outputs[0].filter', 
force=1)
    print 'AOV has been created'
else:
    print 'No need to create a new customAOV'

# get all shading groups
shadingGroup = cmds.ls('aiStandard1SG')[0]
numOfCustomAOVs = cmds.getAttr(shadingGroup+'.aiCustomAOVs', size=1)
print 'Number of custom AOVs'

-- 
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/8ca24586-9a0c-4f3d-bf02-63d9ca5b2a9f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to