OpenMaya command that derives animation curve on attribute

Hi all, I need some help with getting animation curves using OpenMaya.

I have 3 cases in which nodes in scene will be generated:

  • Manual keyed
  • By constrains
  • Use of anim layers

In my code, I was able to get the first scenario working. And so I thought it will work for the other 2 but turns out it is not.

Here is my code: and here is an attached scene file

In the code, if you un-comment scenario1 and comment scenario2, I will get the following error:

# Error: (kInvalidParameter): Object is incompatible with this method
# Traceback (most recent call last):
#   File "<maya console>", line 66, in <module>
#   File "<maya console>", line 27, in rotation_check
# RuntimeError: (kInvalidParameter): Object is incompatible with this method # 

Whereas if you comment out scenario1 and uncomment scenario2, a different error will be spawn if the specified node inputted is either [“test_animLayer”] or [“test_constrained”]:

# Error: (kFailure): Object does not exist
# Traceback (most recent call last):
#   File "<maya console>", line 61, in <module>
#   File "<maya console>", line 42, in rotation_check
# RuntimeError: (kFailure): Object does not exist #

My questions would be:

  1. Why does the error between scenario differs (so much) at different line? I would have expected them to error out at line 27 in scenario 1, since “test_animLayer” and “test_constrained” are in the selection…

  2. Given in the above cases, is there an OpenMaya command that I can use to effectively determine either of the cases has an animation curve?

Looks like you didn’t read my actual guess what’s wrong from the other thread … 'cause that’s what it is for scenario 2.

For scenario 1, you should print rig_controls. You’re not getting the objects you think you are.
You’re getting the shapes, not the transforms (which are the parents of the shapes)

As for your second question, you’re going to have to get the node connected to the plug, get the type of node it is (the apiTypeStr), and depending on that type, get the animation data differently.

Also, it would have been preferrable to just keep the other thread going and just provide the extra information. Now that this thread exists, we can continue here.

Hi @tfox_TD, sorry for the very late response.

I managed to come up with a script that does what I wanted, but however the time taken for my script to run thru the rig controllers (about 300 controllers) is seemingly very slow - approx. 15-19 seconds.

Kind of stuck on speeding up the script execution as the slowness seems to be occuring at the has_flip() method.

This script of mine was based off my old script (that only works on keyed values). Wondering if you or anyone else could kindly share insights on this?

For your reference, I have put in links to both the old and new code that I had done.