Page 1 of 1

MEL question: expressions in annotations

Posted: Thu Jul 12, 2007 5:41 pm
by deadalvs
hey there !

i have this question:

i have to create locators with (each) an annotation of it's actual Y-Coordinate that is updated as the object is moved...

how/where can i write this expression or automate the creation of a locator with this feature ?

thanks a lot !
:D

Posted: Thu Jul 12, 2007 6:23 pm
by DrMerman
Hey man,

Try this :
Code: Select all
//create locator and annotation
         spaceLocator -p 0 0 0 -n "myAnnotatedLocator";
         createAnnotation "Y Value is 0";

//get annotation details
         select -r "myAnnotatedLocator";
         PickWalkDown;PickWalkRight;PickWalkDown;PickWalkRight;
         global string $annoName[];
         $annoName = `ls -sl`;

//start scriptjob to update annotation on locator height change
         int $annoUpdate = `scriptJob -ac myAnnotatedLocator.ty "annoUpdateProc"`;

//reselect locator
         select -r "myAnnotatedLocator";

////////////////////////////////////////////////////////////////////////////////////

//proc to update annotation

global proc annoUpdateProc()
{
global string $annoName[];

//delete old nodes
         delete $annoName[0];
         select -r myAnnotatedLocator;
         PickWalkDown;
         PickWalkRight;
         doDelete;

//get locator height
         float $locatorHeight = `getAttr myAnnotatedLocator.ty`;
         
//create new annotation
         select -r myAnnotatedLocator;
         string $annotationLabel = ("Y Value is " + $locatorHeight);
         createAnnotation $annotationLabel;
         
//reselect locator
         select -r myAnnotatedLocator;
}
Cheers,

Matt :)

Posted: Thu Jul 12, 2007 11:21 pm
by deadalvs
hey !

thanks doc... long time no read... :P

* * *

i tried this and the approach seems nice.

i only have a few problems:

1[
when trying to scale down the locators to 0.01 and move the main locator, it scales back to 1.

2[
after creating a second creator with the same script, the stuff does not work any more... (could be done by correct renaming of course)

ah damn, i'll need lots of locators with the y value displayed... :(

let me think some more.

Posted: Sat Jul 14, 2007 6:54 pm
by deadalvs
ah well. i just named the annotations after their height. i don't have to move them so many times...

anyway thanks for that input.

but i have an other question.

how can i select all the children of an object without the object itself?

le's say there are two curves under a parent node and i have the parent node currently selected...

Posted: Sun Jul 15, 2007 1:02 am
by deadalvs
ha !
found:

listRelatives -children [nodename];