我有一个Python脚本,该脚本将立体摄像机的属性存储到json
文件中,但是在存储镜头长度属性时遇到了麻烦。我是Maya的新手,这可能是一件很明显的事情,所以我感谢您的投入。
这是我到目前为止尝试过的:
import maya.cmds as cmds
print(cmds.getAttr("cameraMain_C0_ctl.lensLengths"))
我期望看到15
或15mm
的值,但我得到零。
a screenshot of the attribute I am trying to store
是否可以存储该值?
谢谢。
答案 0 :(得分:3)
使用以下代码获取属性(相机shapes
):
import maya.cmds as cmds
focalLengthCenter = cmds.camera("stereoCameraCenterCamShape", q=True, fl=True)
focalLengthLeft = cmds.camera("stereoCameraLeft", q=True, fl=True)
focalLengthRight = cmds.camera("stereoCameraRight", q=True, fl=True)
print(focalLengthCenter, focalLengthLeft, focalLengthRight)
# Result (70.0, 70.0, 70.0)
希望这会有所帮助。