PDA

View Full Version : How to setup interactive control with MEL


BluesmanI
02-04-2008, 03:11 AM
Hi guys,

i'm new to MEL and want to write a simple script that controls stuff interactively.

It doesn't have to have capabilities like the virtual slider, just enter an attribute value -> and after pressing enter start the script.

I tried to setup an expression, but as controlled by time1 it only gets evaluated when moving the time slider.


Many thanx in advance
Blues

ManuelM
02-04-2008, 06:15 AM
that description of what you want to achieve is extremely vague. pls try to explain more precisely what the script shall do and the forum members might be able to help you.

BluesmanI
02-04-2008, 06:47 AM
At first, thanx for the reply.

Example:

I have a locator as dummy object. I added a custom attribute (int) named "moveVerts" to that locator. The values for that attribute are Min=0, Max=5 and Default=0.


The script looks as following

int $relativeDistance = `getAttr locator1.moveVerts`;

select pCube1.vtx[0:3];

move -r 0 0 $relativeDistance pCube1.vtx[0:3];



Everytime i change the value of the attribute "moveVerts" I want to have the verts transformed immediately. If i set the code into an expression this only happens when I move the time slider.
The action should take place more or less "on demand" as connected to time.


I know that i could take the verts into a cluster and simply connect the cluster's transformZ to the attribute, but the upcomin' script will be a bit more complex. ;-)


Hope this helps.

tbaypaul
02-04-2008, 06:35 PM
in the maya docs look up scriptJob in the commands section....these examples are from it....if you make your own window with a float slider it (the slider) will have a builtin changeCommand that will eliminate the need for a scriptJob.


// create a job that deletes things when they are seleted
int $jobNum = `scriptJob -ct "SomethingSelected" "delete" -protected`;

// Now display the job
scriptJob -listJobs;

// Now kill it (need to use -force flag since it's protected)
scriptJob -kill $jobNum -force;

// create a sphere, but print a warning the next time it
// is raised over 10 units high
global proc warn(){
float $height = `getAttr mySphere.ty`;
if ( $height > 10.0 ){
print ("Sphere is too high!\n");
}//end if
}// end proc

sphere -n mySphere;
scriptJob -runOnce true -attributeChange mySphere.ty warn;


You would replace warn() with your "expression".

BluesmanI
02-04-2008, 10:49 PM
Oh yeah, that's the solution. Thank you so much, guys.


cheers
Blues

CGTalk Moderation
02-04-2008, 10:49 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.