scriptJob

Hello,

I stumbled upon a Maya scriptjob problem that I can’t find a fix for. After doing some reading, an old thread mentions a similar problem here: http://forums.cgsociety.org/showthread.php?t=743020

What I am trying to do is to write a space switching scriptjob. (is it the best way to deal with no-pop space switching?). I write code daily, but never use scriptjobs, and this one got me stuck for too long. Here is my situation:

I have an enum attribute with the list of spaces, and a list of attributes that correspond to the values of the enum list. The switch works fine at first… but if you set keys, and hit the playback button, the scriptjob gets executed almost each time you hit the stop button.

In the example from the referenced post, his scriptjob sets a key each time you hit stop.
In my case, when changing the enum value, my scriptjob checks the attr that has a value of 1, if it’s the same, it’s does nothing; if it’s different, I have a pop-up confirmBox giving 3 options: [switch and set key], [switch without setting key], [cancel].
It’s good because I can cancel it, but it’s annoying to see it each time I hit play. (and I have 4 space switchers - for each limb - so I get the popup 4 times)

Keys are set to the attributes, so when you go and press stop on a frame where they match, it’s fine, but if you press stop where the attribute doesn’t match the enumList, the script is triggered so I get the popup.

Is there a way to have the scriptjob executed really only on ‘attributechange’ by user? Is there a way to ignore the timeline/playback?

I hope I can get a solution here. Again, I have the option to ‘Cancel’, so it’s not breaking anything in the scene, it’s just very frustrating.

Thank you,
P.

I haven’t set up a SpaceSwitching scriptJob myself yet so just spitballing, but maybe try this:
Compare the value of the enum on the frame to the previous key. If it matches, ignore the dialogue and don’t set a new key. If it doesn’t match, prompt the user.

That should be lightweight and circumvent the dialogue when it’s not needed.

You need to make that attribute non-keyable, that will allow the animators to trigger the scriptJob but won’t keep triggering during playback.

And scriptJobs work for it, I had it one for IKFK matching in one of our rigs working the same way =)

just to add,If you want to display what space it is in you can always place an attribute that has the same names and is keyframed with the switch but just isn’t doing the driving.

Thanks for the responses guys.

lkruel, my IK/FK matching works fine, that one doesn’t give me any bugs.

My enums are already not keyable. I have a list of attributes corresponding to each space that get keyed. When the enum is changed, I compare the values and prompt to apply the switch if they are different.

Since the enum is not keyable, its value doesn’t change if you playback. If you stop on a frame where the enum and the active attribute is different, it will trigger the script job.

Scriptjobs are just kind of funny like that - they like to activate on their own. What I did with mine was to build in a stopper. There’s a MEL command that allows you to view what the last action taken was, so you can tell the script to skip the important bits unless the last action was the one you wanted. The command is undoInfo -q