- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I've ran into an issue with a script job calling its callback function when it shouldn't. Specifically, if I make a locator, put an enum attribute on it, key the enum attribute, then create a attributeChange scriptJob who calla a function when the enum attribute changes, the event fires whenever I go to a new keyframe regardless of whether the attribute changes or not.
Below is a Python script that will setup that specific example. For it to break (which is what this demonstrates), you must select the locator after this script is ran (not its shape). Now go to any frame, and the script editor will erroneously update with "attribute changed.", when in fact the attribute has not been changed.
I'm guessing this is a bug, but if anyone knows otherwise, with a work-around, I will gladly give you 3 million dollars shortly before I wake up in the morning 🙂
import pymel.core as pm # Make a locator locator = pm.createNode('locator').getParent() # Creating enum attribute with 2 stepped keyframes locator.addAttr('my_enum', attributeType='enum', enumName='foxtrot:zulu:') locator.my_enum.setKeyable(True) locator.my_enum.setKey(time=10, value=0) # Create even with callback function def my_func(): print('attribute changed.') job_id = pm.scriptJob(attributeChange=[locator.my_enum, my_func])
Remember, manually select the locator after running the script for the problem to occur.
-Paul
Solved! Go to Solution.