Rigging

Rigging101 » Rigging128

Running a Script on Attribute Change (5 posts)

About This Topic

Tags

No tags yet.

  1. mzahmbie

    offline
    Member
    Posted 7 years ago
    #

    Hey everyone, I'm trying to implement auto snapping for space switching, I wrote up a script that handles the snapping with a shelf button press but I'd like to automate it. It would be really convenient if there is a way to have a script execute on the change of a custom attribute. I've been looking through documentation and searches, but haven't found a way to do that yet. ScriptJob looked the most promising, but I didn't see a way to connect the scriptJob to trigger when an attribute on a node was changed.

    I love trying to figure this stuff out, but I'm at a loss right now. Is there any way to set up a script to execute when an attribute on a specific node is changed? Or would I be better off breaking the script down into pieces and using the expression editor to watch for the change and make the changes attribute by attribute instead of all together in a script? Or maybe I'm going about this entirely wrong? ;P

    Thanks in advance for any suggestions on this!

  2. Javier "Goosh" Solsona (admin)

    offline
    Key Master
    Posted 7 years ago
    #

    a scriptJob should be able to do it

    Though I do find that that kind of stuff is better left to a button.

  3. mzahmbie

    offline
    Member
    Posted 7 years ago
    #

    I'll have to dig deeper into scriptJobs. From reading up on it it seemed like it would watch that any attribute changed and I'd have to filter to only execute on the correct one. Which feels terribly inefficient to have a script running that often when it's doing nothing 90% of the time. Thanks for the input Javier! I'm still relatively new to Maya so I may just leave it as a button, especially if I find that the above is true.

  4. Abhijeet

    offline
    Member
    Posted 7 years ago
    #

    if (getAttr name of Attribute == value in which script should run)
    {

    Your script
    }
    Try dis n tel me does it worked..................

  5. mzahmbie

    offline
    Member
    Posted 7 years ago
    #

    Heya Abhijeet, I ended up just keeping it as a button rather than automated so animators would have to decide whether or not they want it. That script would work if I was just running a script, however I was looking for an efficient way for the script to automatically run without having to call a statement. As Goosh said a scriptJob would get the work done, but it would be checking every attribute change for the right one and not just executing when the specific attribute was changed.

Reply

You must log in to post.

Rigging101 » Rigging128
1,099 posts in 307 topics over 110 months by 188 of 8,226 members. Latest: fashionpvp, d2q4p5z2j, gasheldonl