I’ve got to say: Thanks in advanced! This place rules.
Here’s my setup:
I’ve got a controller in the scene that has enum attributes.
Each enum has as set of entries that controls the visibility of pieces of geometry.
Their enum attributes because only one piece of geometry should be present at any given time.
(The attributes are dynamically setup depending on what is in the scene)
Awesome.
Here’s my dilema:
I need to create an “auto key” function. We’ll call it “fb auto key”.
When the user turns this “fb auto key” on:
whenever user changes any of the enums, I want to automatically set a key on the current frame with the new enum, then set a key previous frame of the last used enum.
Would this best be executed by utilizing a ScriptJob?
Also what if the user turns the “fb auto key” function off, do I need to delete those scriptJobs, and then recreate them when user turns “fb auto key” back on, and so forth?
I think you are 90% there without our help. Just create a scriptJob that monitors these attributes for changes when they have it enabled and kill the scriptJob when it isn’t.
[QUOTE=btribble;17780]I think you are 90% there without our help. Just create a scriptJob that monitors these attributes for changes when they have it enabled and kill the scriptJob when it isn’t.
I don’t know whether you are using MEL or Python in your existing tools, but Google has examples of both syntaxes.[/QUOTE]
Thanks!
Is there a way I can use the “runOnce” flag, then have the script job regenerate itself?
(My script jobs are dynamically created based on how many attrs a certain controller in the scene has)
I’m using attribute change as my script job trigger. But the def that get triggered changes the attribute again, thus leading to an infinite loop. (attr changes, script job triggers def which changes attr again, thus triggering the script job again, and so on until… crash!)
So I’m guessing I should use the runOnce flag, but I still need the script job after it’s run the first time, so is there an easy way to have the scriptjob kill itself then regenerate itself after it runsOnce?
it is easier that that. Simply create a global variable (or the equivalent) called something like amRunningScriptJob. When you enter the scriptJob callback, check it, and if it is true, then exit immediately. If false, set it to true, do your stuff, then set if false just before exiting.