0

I want to write a script that will take multiple objects, center their respective pivots and then translate the pivots in y to 0.

Here are two variations of my attempts so far:

string $sel[] = `ls -sl -typ transform`;
string $obj;

for ($obj in $sel) {
    CenterPivot
    setAttr ($obj + ".scalePivot") -ty 0;
    setAttr ($obj + ".rotatePivot") -ty 0;
}

and

string $sel[] = `ls -sl -typ transform`;
string $obj;

for ($obj in $sel) {
    xform -cp;
    xform -piv 0 -0.098814 0;
}

In the second script the translate y moves to zero (-0.098814 from its start position) but z and x move away from the centre of the source object.

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
shfury
  • 389
  • 1
  • 5
  • 15

2 Answers2

0
string $sel[] = `ls -sl -typ transform`;
string $obj;
for ($obj in $sel)
{
    xform -ws -cp;
    xform -ws -piv 0 -0.098814 0;
}

Adding world space will fix your problem I think.

Achayan
  • 5,720
  • 2
  • 39
  • 61
  • still ends up off in the distance :/ Sorted anyway now - I centered all of the pivots using the above and then manually snapped them down to the grid – shfury Oct 31 '14 at 12:25
0

If I understood you correctly:

for( $i in `ls -sl`){
    select $i; 
    xform -ws -cp;
    $p = `xform -q -piv -ws`;
    xform -ws -piv $p[0] 0 $p[2];}
SAF
  • 309
  • 2
  • 13