Pregunta

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. I can get the timeslider to adjust I am just having trouble finding the keyframe to adjust it to through 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)

edit: sorry basically I import my camera

cams = [cam1,cam2,cam3,cam4]

for x of cams:

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)
¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top