CGTalk > Software > Autodesk Maya > Maya Programming
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 11-02-2005, 06:57 PM   #1
alredha
Frequenter
 
alredha's Avatar
portfolio
Reda Alouache
3D & VFX Generalist
BlinkStudios
Dubai, United%2BArab%2BEmirates
 
Join Date: Nov 2005
Posts: 247
Exclamation selection event!!

hi everybody!

i'd like to know the command that can check if an object is selected or not to use it in the expression editor, as an event trigger, or.......how can i link a mel script to any attribute...for exemple, i added an attribute with boolean content, so if it is set to true, it execute one script(ex: select -r cube1), else, it executes another script.

thank you very much.
 
Old 11-02-2005, 10:54 PM   #2
EigenPuff
Artist's Tool
 
EigenPuff's Avatar
Mike Gonzales
Art Tools Programmer
Crystal Dynamics
San Francisco, USA
 
Join Date: Jul 2005
Posts: 61
Send a message via ICQ to EigenPuff Send a message via AIM to EigenPuff Send a message via MSN to EigenPuff Send a message via Yahoo to EigenPuff
I'm not sure if this is exactly what you are looking for, but to grab a list of everything selected, use 'ls -selection'. For instance,

Code:
string $selectionSet[] = `ls -selection`; int $i; //for everything in the selection set, print it out for($i = 0; $i < size($selectionSet); $i++) { print($selectionSet[$i] + "\n"); }


Notice that this returns everything selected - an array of all the names selected; You may just want to grab the first item selected - $selectionSet[0] - or only operate if one and only one object is selected:

Code:
if(size($selectionSet) == 1) { /*Do stuff with $selectionSet[0]*/ } else /*error*/
 
Old 11-02-2005, 11:07 PM   #3
alredha
Frequenter
 
alredha's Avatar
portfolio
Reda Alouache
3D & VFX Generalist
BlinkStudios
Dubai, United%2BArab%2BEmirates
 
Join Date: Nov 2005
Posts: 247
thanks EigenPuff! it works perfectly, but how can i always evaluate it? put it in the expression editor? or there is another mel command!!!
 
Old 11-02-2005, 11:35 PM   #4
Starrider
Frequenter
 
Starrider's Avatar
portfolio
Daniel Stern
Technical Director
Vancouver, Canada
 
Join Date: Apr 2004
Posts: 209
hey!
i think the scriptjob-command is what you're looking for.
here a little example from the documentation:
// create a job that deletes things when they are seleted
int $jobNum = `scriptJob -ct "SomethingSelected" "delete" -protected`;

with the Flag -attributeChange (-ac) you can run a script everytime a attribute is changed.
but remember that these scriptjobs will slow down your maya and won't work while you play back your scene.
i hope this was helpful!

Last edited by Starrider : 11-02-2005 at 11:37 PM.
 
Old 11-05-2005, 08:57 PM   #5
alredha
Frequenter
 
alredha's Avatar
portfolio
Reda Alouache
3D & VFX Generalist
BlinkStudios
Dubai, United%2BArab%2BEmirates
 
Join Date: Nov 2005
Posts: 247
thank you Starrider! it was really what i was looking for ....

i used it to parent constraint some cubes to any null when it's selected depending on the position of the cubes!, simple ex: we have two nulls -5 0 0 and 5 0 0 and depending on the null selected, we check the X position of all the cubes to see which one should be parent constrained to the current selection, after then, we animate the rotation of the null, so the cubes parented will rotate as well, then we select another null to have its cubes parented to it and we animate it too, its cubes will follow of course, but!....the animation of the cubes that was parented to the first null and then parented to the second had lost thier animation! because they weren't keyframed just thier old parent!........so my question is: how to add a keyframe to an attribute!!! so i will add keyframe in the parent constraint node when the null is selected.......i hope i was clear! ...it was a little chinese
 
Old 11-05-2005, 08:57 PM   #6
CGTalk Moderation
Expert
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,478
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 08:17 PM.


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