View Full Version : How do I assign a mel script to an attribute?

02 February 2008, 03:08 AM
I want to add this attubute to a control and when that attribute is changed to a particular value I want to execute a particular mel code. Can anybody tell me how to do that? or is there a better way than what I am thinking? Thanks.

02 February 2008, 03:27 AM
scriptJob is the way to go.
e.g : scriptJob -attributeChange mySphere.ty warnMe;
(warnMe is the function you want to call)

02 February 2008, 03:47 AM
Thanks I will go through scriptJob. Thanks a lot again.

02 February 2008, 04:55 AM
I have one more question. After I attach a script with the attribute, will it stay with it all the time? I mean everytime I run that maya file that attribute still have that script attached to it?

02 February 2008, 05:50 AM
It seems that the attribute will not retain the scriptJob attached to it. Is there a way to run the scriptJob when i open my file? Is there a way to associate script with a particular file so that when I open only my file it will execute the mel script?

02 February 2008, 06:51 AM
hi theflash,

yes, the scriptjob is retained only this ur current maya session.

Open your scene and put a script node and tell the scriptnode to fire itself before the scene is open and then in the script node you can have the command to make a scriptjob which can be attached to the obj's attribute.

scriptNode -st 1 -beforeScript "scriptJob -attributeChange mySphere.ty warnMee;";

this shud be run everytime ur scene is opened and your scriptjob shud be re-created every time :)

02 February 2008, 08:54 PM
Thanks man. That is going to be very helpful. I will give it a shot.

CGTalk Moderation
02 February 2008, 08:54 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.