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?
# 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'