I'm trying to write a script that makes it easier to create Light AOV's using LPE's (Light Path Expressions). But I just can't find a way to query the existence of previously created AOV's and skip those.
I'm following a tutorial I found from Arvid Schneider so some steps are from his video.
Here is what I have so far:
custAovLst = []
for lightSel in range(len(LightList)):
lgt_name = cmds.listRelatives(LightList, shapes = 1)
aov ='setAttr -type "string" {}.aiAov {};'.format(lgt_name[lightSel], 'lgt_' + lgt_name[lightSel].replace("Shape", ""))
mel.eval(aov)
for light in LightList:
aovName = cmds.getAttr(light + '.aiAov')
custAovLst.append(aovName)
def aovCreate():
for aovPass in custAovLst:
if cmds.attributeQuery(aovPass , node = ".aiAov", ex = True):
pass
else:
lightAov = aovs.AOVInterface().addAOV(aovPass, aovType='rgba')
aiAov = pmc.PyNode(lightAov.node)
aiAov.lightPathExpression.set("C.<L.'" + aovPass + "'>.*")
aovCreate()
Any help or advice on how to achieve this or a better way to go on hits is more than welcome!
I ended up using a list with referenceQuery
command.
aovList = cmds.ls(type = "aiAOV")
deleteNode = [node for node in aovList if 'lgt' in str(node) if not
cmds.referenceQuery(node, inr = 1)]
cmds.delete(deleteNode)