def connectedImgPlanes(self,dagNode):
print "dagNode ",dagNode ,type(dagNode)
sourceConnections = cmds.listConnections(dagNode, source = True) or []
if len(sourceConnections) != 0:
lc = sourceConnections[0].split("->")[1]
atribVal=cmds.getAttr(lc+".imageName")
return atribVal
else:
return ""
上面的函数起作用,并从imageplane的shape节点的imageName属性返回文件名路径,但是如果top camera设置了imageplane,那么上面的函数就不起作用了,在这种情况下,我得到一个错误消息:error:line 1:IndexError:file line 1:list index out of range#,原因是
^{pr2}$然后我尝试了不同的方法来获取imageplanes的shape节点并从中返回一个属性
lc=""
try:
lc=cmds.listRelatives(cmds.listRelatives(dagNode)[0])[0]
except TypeError:
return ""
print lc
atribVal=cmds.getAttr(lc+".imageName")
return atribVal
这个方法同样有效,直到我们添加了顶部摄像头,并且代码开始给出不同类型的错误,说明有多个对象与名称匹配:imagePlane1#
请有人帮我得到每个相机的形状节点,并返回空字符串,如果相机没有设置图像平面。。。在
由于
imagePlanes
(dependNode)不能有任何shape
节点,因此我假设它是您想要的imageName
属性。在下面的函数,如果传递了
camera
,将返回附加到它的任何imagePlane
的imageName
属性。如果传递了一个transform
,它将查找到它的任何camera
连接,然后返回找到的相机上任何imagePlanes
的imageName
属性。在相关问题 更多 >
编程相关推荐