No tags yet.
Hi
I have a city with buildings (rectangles) placed around the scene that have their translation values zeroed out when they are where they shold be.
I need a script that queries their relative offset from the worldOrigin and sets it as their translation value. (unreset/unfreze) So that if a cube is placed at WS [1,1,1] its translation value is [1,1,1] and not [0,0,0].
xform shold be able to query the position and than i shold be able to setAttr if i made a loop right?
Will some of you MEL Wizards help with this?
heres a snapshot of the city:)
http://www.facebook.com/photo.php?pid=3947939&l=54314cf20a&id=574437196
cheers
that's not very difficult:
// center pivot
xform -cp;
// get translate from new pivot
float $pivot[] = getAttr ".rotatePivot";
//move to origin
move -r (-1* $pivot[0]) (-1 * $pivot[1]) (-1 * $pivot[2]);
// freeze transforms
makeIdentity -apply true -t 1 -r 1 -s 1 -n 0;
//reset transforms
makeIdentity -apply false -t 1 -r 1 -s 1;
//move object back to newly found pivot;
move -r $pivot[0] $pivot[1] $pivot[2];
Thank you for replying.
I select all the objects i want to reReset pivot for and run the script...and
for some reason i am getting error:
// Error: float $pivot[] = getAttr ".rotatePivot"; //
// Error: Invalid use of Maya object "getAttr". //
I am using MAya2010 64bits....cout it be the reason?
And if you want to have a look at the scene its here:
http://www.opendrive.com/files/5946137_ch06F_6424/UnrealOsloDanny.ma
Apriciate it.
What I wrote works on a single object. If you want too use it on all models, put it in a for loop like this and select all models
$sel = ls -sl;
for ($tmp in $sel) {
// center pivot
xform -cp $tmp;
// get translate from new pivot
float $pivot[] = getAttr ($tmp + ".rotatePivot");
//move to origin
move -r (-1* $pivot[0]) (-1 * $pivot[1]) (-1 * $pivot[2]) $tmp ;
// freeze transforms
makeIdentity -apply true -t 1 -r 1 -s 1 -n 0 $tmp;
//reset transforms
makeIdentity -apply false -t 1 -r 1 -s 1 $tmp;
//move object back to newly found pivot;
move -r $pivot[0] $pivot[1] $pivot[2] $tmp;
}
strange, it now says:
"$tmp" is an undeclared variable. //
and I tried the previous script with a single object but it still gave me the same error:
// Error: float $pivot[] = getAttr ".rotatePivot"; //
// Error: Invalid use of Maya object "getAttr". //
gotit:)
it was the
ls -sl
:)
thanx aLOT
Ooooops ....It turns out that I also need to reReset the rotation values :)
----Help-----Thanx---
:)
Heres the script that worked for translation
$sel = ls -sl;
for ($tmp in $sel) {
// center pivot
xform -cp $tmp;
// get translate from new pivot
float $pivot[] = getAttr ($tmp + ".rotatePivot");
//move to origin
move -r (-1* $pivot[0]) (-1 * $pivot[1]) (-1 * $pivot[2]) $tmp ;
// freeze transforms
makeIdentity -apply true -t 1 -r 1 -s 1 -n 0 $tmp;
//reset transforms
makeIdentity -apply false -t 1 -r 1 -s 1 $tmp;
//move object back to newly found pivot;
move -r $pivot[0] $pivot[1] $pivot[2] $tmp;
}
You must log in to post.