Search code examples
mel

Activating mel script or global proc during attribute change


I have developed a hand IKFK snap tool for my character but, if have to run that script , i have to copy paste that script editor to run it or use shelf button to activate it.

Is there any way that i can run the command, if i change my attribute Value From Ik to Fk in my attribute editor itself

sorry for my English (R.I.P)


Solution

  • You can set up a scriptJob to run a script when some event happens. AtributeChange is one such event.. there are plenty others.

    global proc ikfkSnap() {
        int $val = `getAttr "mySkelControl.switchIkFk"`;
        print ("changing ik/fk mode to "+ $val);
        // ....
    }
    
    int $scriptJobNum = `scriptJob -attributeChange "mySkelControl.switchIkFk" "ikfkSnap" `;