How to setup interactive control with MEL

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 02 February 2008   #1
How to setup interactive control with MEL

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
 
Old 02 February 2008   #2
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.
__________________
Manuel Macha
website: www.manuelmacha.de

 
Old 02 February 2008   #3
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.

Last edited by BluesmanI : 02 February 2008 at 06:52 AM.
 
Old 02 February 2008   #4
use a scriptJob

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".

Last edited by tbaypaul : 02 February 2008 at 06:37 PM. Reason: bad spelling
 
Old 02 February 2008   #5
Oh yeah, that's the solution. Thank you so much, guys.


cheers
Blues
 
Old 02 February 2008   #6
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 05:00 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.