[Maya-Python] Query keyframe time

538 views
Skip to first unread message

Bradon Webb

unread,
Jun 2, 2012, 12:14:55 PM6/2/12
to python_inside_maya
I have a keyframed object and and I want to query it at 2 different
times so I can define the magnitude of change over time.

here is what I have for query the keyframe at current time. this
works fine:

selectedNode = mc.ls(selection=True)[0]
keyframe = mc.keyframe(selectedNode, query=True, eval=True)
print keyframe

but when I try to specify time it wont work:

selectedNode = mc.ls(selection=True)[0]
keyframe = mc.keyframe(selectedNode, query=True, eval=True,
time=5)
print keyframe

# Error: TypeError: Invalid arguments for flag 'time'. Expected
(time, [time]), got int #

Justin Israel

unread,
Jun 5, 2012, 11:30:36 AM6/5/12
to python_in...@googlegroups.com, python_inside_maya
The docs for the "time" attribute are a little confusing. Probably a bad translation from the mel version.
But the examples below it, and your traceback error are pretty helpful about the correct format.
http://download.autodesk.com/us/maya/2010help/CommandsPython/keyframe.html#hExamples

It requires a tuple representing a time range: (start, [end])
The brackets around the end imply its optional. If you are only doing one frame, you will see it like this: (5, 5)
You can do a singly element tuple like: (5, )
I forget if thats valid though. The error suggests its fine.
> --
> view archives: http://groups.google.com/group/python_inside_maya
> change your subscription settings: http://groups.google.com/group/python_inside_maya/subscribe

Bradon Webb

unread,
Jun 7, 2012, 6:01:48 PM6/7/12
to python_in...@googlegroups.com
very good, that works perfectly.  Thanks!
Reply all
Reply to author
Forward
0 new messages