PDA

View Full Version : scriptjob on enum attribute change not working properly


martinputtkammer
03-26-2008, 01:03 AM
hi folks,

i use "scriptjob" with "attribute change" for an enum attribute (for multi constraint switching).
it works fine BUT everytime the enum value gets changed by the user once mel still calls the
scriptjob command several times. sometimes it is three times, sometimes 20 times but never
once, as would equal the number of attribute changes in that case.

is there a way to fix this?

thanks a bunch,
martin

GiantG
03-26-2008, 08:00 AM
Hi.

Have you tried the -runOnce flag?


-runOnce(-ro) boolean
If this is set to true, the script will only be run a single time. If false (the default) the script will run every time the triggering condition/event occurs. If the -uid flag is used, runOnce is turned on automatically.

martinputtkammer
03-26-2008, 10:00 AM
hi GiantG,

the thing is, it is supposed to be executed everytime the switch changes. so once won't do the trick here. tried that already...

thanks anyway,
martin

martinputtkammer
03-26-2008, 03:41 PM
solved it using a bypass:

i declared a global helper variable for each the "on" condition and the "off" condition.

the respective scripts for "on" and "off" are placed within an if clause which checks
if the respective global helper variable is zero and at the end of the clause the global helper variable is set to one. afterwards this helper variable can only be set to zero by the other switch action.
so the scripts are executed once before stopping themselves and the only way to get
them running again is to have the other switch condition being executed.

that way the surplus "scriptjob changeAttr" callings of maya can be suppressed.

martin

martinputtkammer
03-26-2008, 03:43 PM
solved it using a bypass:

i declared a global helper variable for each the "on" condition and the "off" condition.

the respective scripts for "on" and "off" are placed within an if clause which checks
if the respective global helper variable is zero and at the end of the clause the global helper variable is set to one. afterwards this helper variable can only be set to zero by the other switch action.
so the scripts are executed once before stopping themselves and the only way to get
them running again is to have the other switch condition being executed.

that way the surplus "scriptjob changeAttr" callings of maya can be suppressed.

martin

CGTalk Moderation
03-26-2008, 03:43 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.