selection event!!

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 11 November 2005   #1
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 November 2005   #2
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,


  	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:


  	if(size($selectionSet) == 1)
  	{
  		/*Do stuff with $selectionSet[0]*/
  	}
  	else
  		/*error*/
  
 
Old 11 November 2005   #3
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 November 2005   #4
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 November 2005 at 11:37 PM.
 
Old 11 November 2005   #5
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 November 2005   #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 01:09 AM.


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