PDA

View Full Version : Simple but hard


Gabester
08-09-2005, 08:24 AM
Hi all,

I'd like to assign a 1st selected objects rotate values to a float variable, then apply those values to the secondly selected objects varibles.

This is what I have so far:
string $newone[] = `ls -selection`;
float $newobjectrot[] = `xform -q -ws -rotation $newone`;

/// why doesn't this work? ( I want to take the values and apply
// it to the rotation of this other object)

rotate $newobectrot pSphere1;

??? This doesn't work for some reason. Any ideas??

onkelandy
08-09-2005, 10:14 AM
string $newone[] = `ls -selection`;

float $newobjectrot[] = `xform -q -ws -rotation $newone`;

$newobjectrotX=$newobjectrot[0];

$newobjectrotY=$newobjectrot[1];

$newobjectrotZ=$newobjectrot[2];

// just split the array to the single axis - then it works like a charm..

rotate $newobjectrotX $newobjectrotY $newobjectrotZ pSphere1;

drGonzo
08-09-2005, 10:22 AM
//get selected object
string $sel[]=`ls -sl`;
//re-assign first element in array
string $firstObject = $sel[0];
//re-assign second element in array
string $secondObject = $sel[1];
//Get rotation values of first element
float $rot[]=`xform -q -ws -rotation $firstObject`;
//assign them to second object
xform -ws -rotation $rot[0] $rot[1] $rot[2] $secondObject;

Gabester
08-10-2005, 03:47 AM
Thanks guys. That turned out to be very useful info. But now Im stuck when I go to move the object to the new objects position.

Say for example the object to be moved has been frozen a few times and is somewhere in worldspace. It assumes that that area it is in is 0 0 0 xyz, when in fact its somewhere 5 units in the x and 4 units in the y. How do I get it's current "Actual position" in the world?

drGonzo
08-10-2005, 06:16 AM
You should use this then:
xform -q -ws -rp;

Stucky
08-11-2005, 10:21 AM
Hey. I've used the drGonzo code, and completed it. Now it checks the rotationPivot in the world space, an then he applies those values in the absolute mode using the move command. its the same thing as going to that text box at right of render globals icon, choose "Numeric Input: Absolute", and assign the values that the xform -q -ws -rp returned, but its done all in one time by the code. I think this will work for you. Cheers guys...


//check the objects that are selected
string $sel[]=`ls -sl`;
//the first object in the array
string $firstObject = $sel[0];
//the second object in the array
string $secondObject = $sel[1];
//Get the rotation values of first object
float $rot[]=`xform -q -ws -rotation $firstObject`;
//Assign the rotation values on to the seconf object
xform -ws -rotation $rot[0] $rot[1] $rot[2] $secondObject;
//Get the translation values of first object
float $trans[]=`xform -q -ws -rp $firstObject`;
//Assign the translation values on to the second Object
move -rpr $trans[0] $trans[1] $trans[2] $secondObject;
//Print the done Work
print "Done: The objects are in same place now!";

-S


P.S.: This also works for translation!

CGTalk Moderation
08-11-2005, 10:21 AM
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.