Maya: Figuring out when an attribute is changed by the user vs. by timeline

Hey y’all,

I’m using scriptJobs to identify when a user translates a particular object in a scene.

cmds.scriptJob(ro=True, attributeChange=['{0}.t'.format(wristControl), warnWristTranslate])

Problem is, I only want the scriptJob to be executed when the user is manually keyframing the object. The scriptJob executes when the user scrubs through the timeline, since its translations are changing. Is there a way for me to restrict this behavior?

Last I looked there was no built in way to determine that. Many would advise against using attributeChange scriptJobs on keyable attributes for this reason. I believe it is possible but only via a dirty hack involving querying the undo queue to check whether the last action was time changed. i.e. cmds.undoInfo(q=True, undoName=True) and then string compare what you get back.

IMHO that hack should be a last resort. There may be another approach that would be cleaner in the long run. e.g. locking those attributes and only allowing edits via a custom tool or context? Not sure what you’re actually wanting to achieve so it’s difficult to make a meaningful suggestion.

I’m trying to build a hybrid IKFK setup, i.e. the chain acts as IK when controls are translated and FK when they’re rotated. I’ve seen some hybrid setups floating around the internet, but haven’t seen any explanations for how they’re done.

if that s what you want to do, the right way to do so is to code a manipulator with the api

As above really, look into setting up callbacks using the API.

m.