简体   繁体   English

Maya Python和相机动画

[英]Maya python and camera animation

Hey so in maya using python I am importing cameras that are locked with keyed animation on them and I just wanted the timeslider at the bottom to update to the length of animation of the imported camera. 嘿,所以在Maya中使用python我正在导入使用键控动画锁定的摄像机,而我只希望底部的时间滑块更新为所导入摄像机的动画长度。 I can get the timeslider to adjust I am just having trouble finding the keyframe to adjust it to through python. 我可以调整时间滑块进行调整,只是找不到通过python进行调整的关键帧。

(example: I import 4 cameras. 1 camera is 10 keyframes. 2 and 3 are 15 keyframes. and then 4th is 52. So I want the timeslider to be 1-52. I can get it to move but i dont know how to find the number 52) (例如:我导入了4个摄像头。1个摄像头是10个关键帧。2和3是15个关键帧。然后第4个是52。所以我希望时间滑块为1-52。我可以移动它,但是我不知道如何找到数字52)

edit: sorry basically I import my camera 编辑:抱歉,基本上我导入我的相机

cams = [cam1,cam2,cam3,cam4]

for x of cams: 对于x的凸轮:

cmds.file(x, i=True, dns=True, rnn = True) #i for import

 # this is how i change the timeslider but I want it to
 # be the number of keyframed animation on the camera
cmds.playbackOptions(max=1000)
camera = 'Camera1'
channel = 'translateX'
keyframes = cmds.keyframe('{}.{}'.format(camera, channel), query=True)
first, last = keyframes[0], keyframes[-1]
cmds.playbackOptions(min=first, max=last, ast=first, aet=last)

This works regardless of whether or not the channels are locked. 无论通道是否被锁定,此方法均起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM