PDA

View Full Version : get values from -no return value- commands


meagane
10-26-2006, 03:45 PM
is it somehow possible to get the values, which have been created with the transformation manipulators, into variables??

I`m getting crazyyyyyyyyyyyyyyyyyyyyyyyyyyy...............

sparaig
10-27-2006, 01:13 AM
is it somehow possible to get the values, which have been created with the transformation manipulators, into variables??

I`m getting crazyyyyyyyyyyyyyyyyyyyyyyyyyyy...............


You can query the objects using xform -q...

move -r $x $y $z $anObject;
$myTransform = `xform -q -t -r $anObject`;

this seems only marginally easier than...

xform -r -t $x $y $z $anObject;
$myTransform = `xform -q -t -r $anObject`;

meagane
10-28-2006, 09:04 AM
xform doesn`t the job..

when I, for example, rotate the rotation manipulator, the command:

rotate -r -os -10.310194 3.116421 7.976138 ;

shows up. I need to get these values into variables...........

sparaig
10-29-2006, 10:08 PM
xform doesn`t the job..

when I, for example, rotate the rotation manipulator, the command:

rotate -r -os -10.310194 3.116421 7.976138 ;

shows up. I need to get these values into variables...........

Yes, and when you do:

//select an object

float $myTransform[];

rotate -r -os -10.310194 3.116421 7.976138 ;
$myTransform = `xform -q -r -ro`;
print $myTransform;

// you will find that $myTransform contains -10.310194 3.116421 7.976138

the "-q" flag means "query," so it has a return value (3 floats in this case).

meagane
10-30-2006, 10:05 AM
yes, you are right,

but how can I get these values when I manipulate, for example, the rotation manipulator???

kojala
10-30-2006, 11:31 AM
Have I understood correctly? You want to use rotate manipulator and at the same time
you want to get the rotating values printed or to be used in a tool that you`ll be using next.
correct?

if this is the case the "scriptJob" comman might do the trick.

meagane
11-01-2006, 08:55 AM
it seem you understand me..

but I don`t find any condition or event to finally get those values from the rotation manipulator....!?!

sparaig
11-02-2006, 07:19 PM
it seem you understand me..

but I don`t find any condition or event to finally get those values from the rotation manipulator....!?!


The following works the first time something is selected then rotated. You could set the scriptjob in monitorRotation() to change the
current script job whenever the selection changed and use "protected" instead of "RunOnce" so that it would keep working as long as the object was selected. If you do that and don't delete the previous scriptjob first, I suspect your list of script jobs would fill up very quickly:


global proc itRotated()
{
string $theSelected[] = `ls -selection`;
print ("by golly " + $theSelected[0] + "rotated!\n");
}

global proc monitorRotation()
{

string $theSelected[] = `ls -selection`;

$cmd = $theSelected[0] + ".rotate";
scriptJob -runOnce true -attributeChange $cmd itRotated;
};

int $jobNum = `scriptJob -ct "SomethingSelected" "monitorRotation" -protected`;

sparaig
11-02-2006, 07:57 PM
Just because I'm anal retentive, here's a complete working script. Only works with the zeroth selection in the selection list though. Haven't tested it for multiple selections:



global int $giveuslocalscriptvarsdammitScriptJobNum;

global proc itRotated()
{
string $theSelected[] = `ls -selection`;
print ("by golly " + $theSelected[0] + "rotated!\n");
}

global proc monitorRotation()
{
global int $giveuslocalscriptvarsdammitScriptJobNum;

string $theSelected[] = `ls -selection`;
if($theSelected[0] != "")
{

$cmd = $theSelected[0] + ".rotate";
if ( $giveuslocalscriptvarsdammitScriptJobNum>0)
scriptJob -kill $giveuslocalscriptvarsdammitScriptJobNum -force;
$giveuslocalscriptvarsdammitScriptJobNum = `scriptJob -attributeChange $cmd itRotated -protected`;
}
}

int $jobNum = `scriptJob -e "SelectionChanged" monitorRotation -protected`;

sparaig
11-02-2006, 08:01 PM
Just because I'm anal retentive, here's a complete working script. Only works with the zeroth selection in the selection list though. Haven't tested it for multiple selections:


[/...]
int $jobNum = `scriptJob -e "SelectionChanged" monitorRotation -protected`;

Note that the flag changed from -ct to -e...

CGTalk Moderation
11-02-2006, 08:01 PM
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.