May 2002
1 / 8
May 2002
Nov 2016

I want be be able to select an object and have a locator created at its pivot point (not at the center of it's bounding box). There must be some way to do this or create a script for this... any advice would be greatly appreciated. -lincoln

  • created

    May '02
  • last reply

    Nov '16
  • 7

    replies

  • 14.9k

    views

  • 1

    user

This should work:

{
string $selection[] = ls -sl;
int $i = 0;
for ($i =0; size ($selection) > $i; $i++) {
float $getPvPos[] = xform -q -ws -piv $selection[$i];
spaceLocator -p 0 0 0;
xform -ws -t $getPvPos[0] $getPvPos[1] $getPvPos[2];
}
}

For all the selected object it will create a locator at the world space position of the pivot.

Hope this help.

-a

float $getPvPos[];
string $selection[] = ls -sl;
int $i = 0;
for ($i =0; size ($selection) > $i; $i++)
{
$getPvPos= xform -q -ws -piv $selection[$i];
spaceLocator -p 0 0 0;
xform -ws -t $getPvPos[0] $getPvPos[1] $getPvPos[2];
}

Hello,

sorry just out of couriosity whats the difference other then the Float veriable and the rest of the procedure is now outside a scope and the variable now are keps as global?

When you decler something in a scope { } maya will destry the variable as soon as the scope as been execute it's most of the time usefull to actually inclue { } in your script editor so the variable are gettin cleaned all the time.

Also re-decler a variable can be usefull so you do not have garbage value. this of course is my honest opinion but I would like to know why do you reckon you should change the script there is always something to learn about .

Just out of couriousity.

Thanks,

-a

My bad,

for some reason the first time I tried your script, I kept getting a syntax error. It said that the $getPvPos var was not declared. I just tried to use your ver and it works. Must have missed a bracked or something when copying it.

Once again I apologize

Sorry .... didnt mean to make a big deal I was just courious to know if you had any particular reason to change the script there is always room for improvements and I was looking to learn something new

Thanks.

-a

thank you so much! it works great! This Highend community is such a great resource, i hope i am able to contribute myself soon.

14 years later