Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

Playback calling scriptJobs unintentionally

Playback calling scriptJobs unintentionally

kirbysteele
Advocate Advocate
998 Views
6 Replies
Message 1 of 7

Playback calling scriptJobs unintentionally

kirbysteele
Advocate
Advocate

Hello All,

 

I have a question about what is really happening when you press the playback button in Maya. I have built a rig that has a few scriptJobs attached to certain controls which seem to be getting called when I press play. They should only be called when I change an attribute on a control. For example there is a finger control that calls a function to create a window GUI for saving finger positions. To activate the window function you have to select the control then change the attribute called "Save Finger Position" from off (0) to Save (1). 

 

The weird thing after playing an animation and then stopping playback the finger GUI appears as though the control had been selected and the attribute had been changed. My question is does anybody know what is really happening during the playback function. Why would a scriptJob bound to a specific controls attribute get called when I hit the play button? If I scrub the timeline or advance frame by frame this doesn't happen. 

 

Here is one of the scriptJobs in case it helps solve the issue : 

  scriptJob -attributeChange "Hailey_R_Finger_Position_ctrl.R_Save_Finger_Positions" "KC_Hailey_SaveFingerPositionsWindow()"

0 Likes
Accepted solutions (1)
999 Views
6 Replies
Replies (6)
Message 2 of 7

kirbysteele
Advocate
Advocate

Hello All,

 

Working on this bug some more today and found a new relevant detail that might help find a cause. The warnings and errors don't appear unless there are keyframes on at least one control. So if I play the timeline and there is no keyframe information then scriptJobs are not called unintentionally. Anybody with insight into what is going on under the hood with the playback functionality would be very much appreciated.

0 Likes
Message 3 of 7

kirbysteele
Advocate
Advocate

Hey @sean.heasley,

 

If you have some time I was just wondering if you might know what happens under the hood during playback. I haven't had any luck getting a response.

 

Thanks!

0 Likes
Message 4 of 7

sean.heasley
Alumni
Alumni

Hi @kirbysteele

 

I'm not a big Animation guru but I think I have an idea how we can check to see what's happening when you playback your animation.

 

  • If you open your script editor
  • Under the MEL tab, type 'commandEcho;'
  • This will show every command and action that is clicked or called in the script editor

Once you do this you can playback your animation and see what appears in the Script Editor. If you don't understand what's appearing on the script editor, feel free to zip your project folder and attach it here or via google drive/dropbox or another software sharing program and I'd be happy to take a look at it!

 

I hope this helps give you the information you're looking for!

0 Likes
Message 5 of 7

kirbysteele
Advocate
Advocate

Hey Sean,

 

Thanks for getting back to me. I have echoCommanded and it confirmed that the function attached to the scriptJob is firing. Unfortunately it looks like that really is all that is happening. There are no other hidden processes running. 

 

Screen Shot 2017-10-05 at 2.35.01 PM.png

At least the errors make some sense because there are three enums on two controls, so it is failing six times. 

 

How that function is activated when playback is not running is that I have an enum on a control and when that enum changes value a scriptJob calls a function that sets the enum back to zero and creates a new GUI. 

 

I guess what I'm trying to figure out is what the playback functionality is doing when there are keyframes on the timeline. The two questions that are eluding me are:

  1. Why would an enum be toggled if that enum attribute isn't even keyable?
  2. If the only time my function is called is by toggling a specific attribute on a specific control, does playback somehow fire functions contained in scriptNodes?

 

0 Likes
Message 6 of 7

sean.heasley
Alumni
Alumni
Accepted solution

Hi @kirbysteele

 

I'm not sure why this is happening but I did some pretty serious digging and thanks to @Anonymous I think I found something that might help!

 

They were having a discussion in this thread about a very similar issue with scripts running on playback similar to the issue you're seeing.

 

Apparently, if the scriptjob -ac is killed when it should not be evaluating it solves the issue.

 

I'm not the best when it comes to scripting, but @Anonymous also made a post on his blog explaining the issue and how he solved it.

 

 

When you get a chance check them out and let me know if they help clarify why this is happening and how to fix it! If his fix doesn't work let me know as well and we'll keep going at it to figure out why this is happening!

 

 

 

0 Likes
Message 7 of 7

kirbysteele
Advocate
Advocate

Hey Sean,

 

Thank you so much for the help! @djiang3 certainly gave me some interesting ideas on a new way to approach structuring scriptJobs. I made progress on removing the errors in my script by having better filtering for names and some more effective conditional statements. However it doesn't address the main problem which is that the scripts are firing when they shouldn't even if there are no more errors. So I will try to blend in this new methodology of removing scriptJobs during time change and adding them during selection change. 

 

Thank you again.