Maxscript Query

I’m trying to get the keyframe positions of a selected object. But I can’t seem to get it working. The code that I’m using right now is :

– get selected markers keyframes.
selMarkers = getCurrentSelection();
for sMarker in selMarkers do
(
mKeys = sMarker.pos.controller.keys;
)

Now this might not be working maybe coze the object has Freeze Transformation. I can’t figure out the syntax for that. So there are two things that I’m trying to figure out:

  1. How can I get keyframes for the object that has Freeze Transformation on it?
  2. Is there a way to get the keyframes of all type of objects, as in the syntax shouldn’t be dependent on Freeze Transformations since I just want the frames that has keys placed?

Hello :):

Are you looking for something like this?

(
	-- get selected markers keyframes.
	local selMarkers = selection as array
	local controlKeyArr = #() --empty array
	for sMarker in selMarkers do
		(
			local mKeys = sMarker.pos.controller.keys
			append controlKeyArr mKeys
		)
	print controlKeyArr
)

…which if you had 3 keyframes set, the result would be,


#keys(0f, 34f, 100f)
#keys(0f, 34f, 100f)
#keys(0f, 34f, 100f)
#keys(0f, 34f, 100f)
#keys(0f, 34f, 100f)
#keys(0f, 34f, 100f)
#keys(0f, 34f, 100f)
#keys(0f, 34f, 100f)
OK

freeze transformations does a few changes to the animation controllers on the object, so sMarker.pos.controller is no longer Position_XYZ, it’s now Position_List after freeze transforms (create a box and then take a look at the Assign Controller rollout in the Motion tab before and after applying freeze transforms to see what exactly happens)

the keys are now stored in the Zero Pos XYZ controller under the Position List, so in your script you want to replace

sMarker.pos.controller.keys

with

sMarker.pos.controller[#Zero_Pos_XYZ].keys

also, if you’re curious to know what freeze transforms does exactly, the script can be found in <install dir>\ui\macroscripts\Macro_FreezeTransform.mcr

Thanx guys, its working now. Now I’m stuck at morph target keys, hehe. I can’t seem to figure out how to get morph target keyframes. What would be the syntax for each morph target keyframe, can we do that? or can we see the keyframes of the selected mesh only?
Thanx again :slight_smile:

Hey Loko try this out.

KeyPos_Array = #()
NoOfMorphKeys = numKeys $.morpher[1].controller
for i = 1 to NoOfMorphKeys do
(
	KeyPosition = getKey $.morpher[1].controller i
	append KeyPos_Array KeyPosition 
)
print KeyPos_Array

The above code prints out the info on keys of the first Morph target

Preeth

Dude you are totally awesome!! Thanx Preeth!