Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

Python API findKeyframe command not working properly

Python API findKeyframe command not working properly

firat.cicekFTQ7L
Explorer Explorer
360 Views
2 Replies
Message 1 of 3

Python API findKeyframe command not working properly

firat.cicekFTQ7L
Explorer
Explorer

Hi, I am facing an issue when using the findKeyframe command.

I was using this command while building a tool but it showed unexpected behaviour.

 

Here I'm using the script editor in Maya 2023.2 to find the previous keyframe before keyframe 5:

firatcicekFTQ7L_0-1666524780261.png

As you can see the value I'm getting is wrong. The value should be 4 because the previous keyframe is keyframe 4.

 

The same thing happens if I specify that I want to get the next keyframe after keyframe 5:

 

firatcicekFTQ7L_2-1666525057591.png

It is supposed to show the value 6 because that's the next keyframe after 5. But the result is still keyframe 5.

 

Does anyone have an idea what the problem is? Is this a bug?

 

Accepted solutions (1)
361 Views
2 Replies
Replies (2)
Message 2 of 3

jmreinhart
Advisor
Advisor
Accepted solution

I just tested this myself in Maya 2023.2 and got the expected result.

cmds.spaceLocator()
cmds.currentTime(4)
cmds.setKeyframe()
cmds.currentTime(5)
cmds.setKeyframe()

print(cmds.findKeyframe(which="previous", time = (5,5)))

Could you run this script as a test? There may be something unusual about your scene that is causing an issue. 

Message 3 of 3

firat.cicekFTQ7L
Explorer
Explorer
Yes, this works for me. Thank you. I realized I had no keyframes in my scene.