Retrieving all keyframes (regardless of type)


#1

I know that you can retrieve keyframes for specific types of animations like this: getKeyTime $.rotation.controller 2. The problem is that you have to know which type of animation to search for, morph animations will as an example not be retrieved by searching for transform controllers.

I did however find that when you have an object selected, you can run at time (1f) trackbar.getNextKeyTime(), and it will retrieve the next key regardless of which type of animation it is. So I would think it’s possible to retrieve the keyframes without having an object selected, no?

My goal is to retrieve the start and the endframe based on all objects in the scene, and I could get it to work by using the example above, but if it’s possible to do this without having objectselection I would prefer that.

Does anyone know how to do this in a efficient way?


#2

Have never done this, but see if this code works.

(
	fn GetStartEndKeys = with undo off
	(
		mapkeys objects (fn CollectKeys t k = (append k t; t)) (keys=#()) #allkeys
		return #(amin keys, amax keys)
	)
	
	GetStartEndKeys()
)

#3

PolyTools3D: You’re a saint man, that worked perfectly! Thank you for sharing some of you magic, I really appreciate it :grinning: