- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to find the last keyframe in a scene doing something like the following:
allXforms = cmds.ls(transforms=True) last = cmds.findKeyframe(allXforms, which='last')
However, I came across a scene where it doesn't work. I reproduced a simple example as follows:
- The scene has multiple animation layers.
- The base animation layer has keys from 1-30.
- The other animation layer has keys from 40-60.
- Animation curves "post infinity" is set to cycle.
When the scene is set up like this, the "findKeyframe" command works on only the actively selected animation layer. So depending on what I have selected, sometimes it returns 30 and sometimes it returns 60.
Question: Is there some way to find the actual last keyframe, taking into account all layers?
Right now I am thinking of finding the currently selected anim layer(s), saving that selection, selecting all the layers, running the "findKeyframe" command, and then restoring the anim layer selection. However, if someone has a suggestion where I don't have to change the selection, that would be much appreciated.
(Attached the simple Maya example scene. But it wouldn't let me attach a .ma file. So I attached it as a .txt file.)
Solved! Go to Solution.