CGTalk > Software > Autodesk Maya > Maya Programming
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 02-04-2008, 03:11 AM   #1
BluesmanI
Veteran
Andy Richter
New Orleans, USA
 
Join Date: Aug 2005
Posts: 58
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-04-2008, 06:15 AM   #2
ManuelM
Lord of the posts
 
ManuelM's Avatar
portfolio
Manuel Macha
Shadowcaster
Animal Logic
Sydney, Australia
 
Join Date: Feb 2002
Posts: 630
Send a message via ICQ to ManuelM Send a message via AIM to ManuelM Send a message via MSN to ManuelM Send a message via Yahoo to ManuelM
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-04-2008, 06:47 AM   #3
BluesmanI
Veteran
Andy Richter
New Orleans, USA
 
Join Date: Aug 2005
Posts: 58
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-04-2008 at 06:52 AM.
 
Old 02-04-2008, 06:35 PM   #4
tbaypaul
Frequenter
 
Join Date: Sep 2004
Posts: 287
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.

Code:
// 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-04-2008 at 06:37 PM. Reason: bad spelling
 
Old 02-04-2008, 10:49 PM   #5
BluesmanI
Veteran
Andy Richter
New Orleans, USA
 
Join Date: Aug 2005
Posts: 58
Oh yeah, that's the solution. Thank you so much, guys.


cheers
Blues
 
Old 02-04-2008, 10:49 PM   #6
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,480
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 01:42 PM.


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