Python 如何查询摄影机是否具有Image plane.py
我试图弄清楚如何查询相机是否有图像平面。 现在,我正在使用此代码找出图像平面的名称,但是,如果“persp”没有图像平面,它会出错:Python 如何查询摄影机是否具有Image plane.py,python,if-statement,runtime-error,maya,Python,If Statement,Runtime Error,Maya,我试图弄清楚如何查询相机是否有图像平面。 现在,我正在使用此代码找出图像平面的名称,但是,如果“persp”没有图像平面,它会出错: line 2: 'NoneType' object has no attribute '__getitem__' # 如果有人能帮助我理解如何在相机出错之前检查相机是否有图像平面 1: camShape = cmds.listRelatives('persp', type='camera', fullPath=True)[0] 2: ip = cmds.list
line 2: 'NoneType' object has no attribute '__getitem__' #
如果有人能帮助我理解如何在相机出错之前检查相机是否有图像平面
1: camShape = cmds.listRelatives('persp', type='camera', fullPath=True)[0]
2: ip = cmds.listConnections(camShape, type="imagePlane")[0]
3: ImageName = ip.split('>')[+1]
4: print ImageName`
谢谢,
Adam你可以检查是否有iplane,然后做一些事情或空列表
camShape = cmds.listRelatives('persp', type='camera', fullPath=True)[0]
ip = cmds.listConnections(camShape, type="imagePlane") or []
if ip:
ImageName = ip[0].split('>')[+1]
print ImageName
谢谢这么简单,我应该得到这个啊哈