Announcements

Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.

Community
Maya Programming
Welcome to Autodesk’s Maya Forums. Share your knowledge, ask questions, and explore popular Maya SDK topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How do I use findKeyframe on animation layer?

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
andy.lathamCJTQT
311 Views, 5 Replies

How do I use findKeyframe on animation layer?

Hi! It is possible to use findKeyframe to find the previous key on a curve by doing something like this:

cmds.findKeyframe("pSphere1", at = "translateX", time = (26, 26), which = "previous")

 

This will also work on a curve in an animation layer, provided the animation layer is the active layer. However I need a way to use the command on an animation layer curve without first changing to that layer. I discovered from selecting a key that the naming of such a curve is "pSphere1_translateX_AnimLayer1_inputB" and so thought I would be able to do this:

cmds.findKeyframe("pSphere1", at = "pSphere1_translateX_AnimLayer1_inputB", time = (26, 26), which = "previous")

 

However this doesn't work. The command can't find the curve. I have also tried "translateX_AnimLayer1_inputB", but that doesn't work either.

 

Does anyone know how to do this?

5 REPLIES 5
Message 2 of 6
Kahylan
in reply to: andy.lathamCJTQT

Hi!

 

When you want to get this information from a not active animation layer, you have to treat the mixer node assosiated with the layer as the node. Also it is worth mentioning that on rotation channels the attributes will be called "inputBX", "inputBY" and "inputBZ" as the rotation is stored on a different kind of node than translation and scale, just to already adress potential future problems.

 

So in your example that would be:

cmds.findKeyframe("pSphere1_translateX_AnimLayer1", at = "inputB", time = (26, 26), which = "previous")

 

I hope it helps!

 

Message 3 of 6
andy.lathamCJTQT
in reply to: Kahylan

Amazing! Thank you soooo much! I have been tearing my hair out over this!

Message 4 of 6

@Kahylan How would I do the same thing, but accessing a key on the base layer while another animation layer is active? Using a simple "translateX" gets a key on the active animation layer, and I don't know of any other way of referencing the base layer.

Message 5 of 6
Kahylan
in reply to: andy.lathamCJTQT

I'm not sure if there is a better way to do this since I don't have too much experience when it comes to anim layers.

But from what I see, the way that anim layers link together is that each attribute has a mixer node (exact type  "animBlendNodeAdditiveDL") which has the attributes inputA and inputB on it, inputA is connected to the output from mixer node from the anim layer below unless it is the first custom anim layer in which case it is simply connected to the base animation curve and inputB is connected to the Animation Curve added by the anim layer.

 

Layers.png

 

So if you want to get the information on the Baselayer, you actually just need to readout the attribute inputA from the mixer node of the first animlayer like so:

cmds.findKeyframe("pSphere1_translateX_AnimLayer1", at = "inputA", time = (26, 26), which = "previous")

Something you'll need to be careful about is that this will cause Errors if you run this on any mixer node from another layer, because the findKeyframe command only works if there is an AnimationCurve connected to the Attribute but not with a mixer node. So you should probably add in an objectType query before the findKeyframe command to make sure you are acctually accessing an animated attribute.

Message 6 of 6

Amazing! Thanks so much @Kahylan! I very much appreciate the help! That worked like a charm.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report