此代码仅在所选摄像机具有图像平面时有效。
所以我想让它弹出窗口,说明当相机没有图像平面时首先添加图像平面。
但是如何检查当前所选摄像机是否有图像平面?
import maya.cmds as cmds
c = cmds.ls(sl=True,dag=True,s=True)
cmds.setAttr((c[0] +
'.nearClipPlane'), 0.5)
cmds.setAttr((c[0] + '.farClipPlane'), 10000000)
ip = cmds.listConnections(c[0], type="imagePlane")
cmds.setAttr((ip[0] + '.depth'), 80000)
答案 0 :(得分:1)
要检查imagePlane
是否存在,您可以执行
import maya.cmds as MC
connection = MC.listConnections('perspShape.imagePlane', type='imagePlane', et=True)
if not connection:
print("No ImagePlane set")
传递给listConnections
et (exactType) only considers the exact given type and ignores derived ones