Change Default Pivot Postion to Bottom?

Change Default Pivot Postion to Bottom?

andymc4997
Advocate Advocate
9,743 Views
15 Replies
Message 1 of 16

Change Default Pivot Postion to Bottom?

andymc4997
Advocate
Advocate

Hi, this may seem like a simple issue, especially for a MEL scripter, but I was simply wondering how I can preset the pivot point of any new poly object to align to the bottom. I like to be a bit more precise with my units, so I prefer to uncheck Interactive Creation and type in W H and D. 

 

Thanks in advance!

 

-Andy

0 Likes
9,744 Views
15 Replies
Replies (15)
Message 2 of 16

sean.heasley
Alumni
Alumni

Hi @andymc4997

 

This would take some fancy scripting to have this change by default.

 

If anything, it would probably be easier to have a script be a button that you can press to set the pivot point to the bottom of the mesh when clicked as opposed to when the mesh is created.

 

 

 

 

0 Likes
Message 3 of 16

andymc4997
Advocate
Advocate

Hi Sean, and thanks for your reply!

 

A button would be fine as well. I guess I assumed it would not actually be hard to script, so thanks for the input there.

 

The process I currently follow is:

 

- After creating object, orbit and zoom to the bottom.

- Hold the D key and select the bottom-most component of the object to reset the pivot point to it.

- Enter 0 for the Y axis in the Absolute Transform area

 

This does seem easy enough, but when modeling multiple objects, it would save time if each new object's pivot point could be preset to the bottom. I'm in the process of modeling many different pieces of furniture and they need to always be "grounded" to the origin. Hope that makes sense.

 

Thanks again

0 Likes
Message 4 of 16

damaggio
Mentor
Mentor

sometimes you can hack a little script from the script editor, here's a button from the Bonus tools pivot script.

Use all the time but don't ask me to change anything, I'm not a programmer.

I think you'll like it.

 

 

source bt_alignPivotToBoundingBoxWin; optionVar -q bt_CenterPivFirst; optionVar -q bt_IndividualBB; bt_alignPivotToBoundingBox 4;

python "import bt_zeroTransforms"; python "bt_zeroTransforms.run( mode='offset' )";

deleteUI bboxPivotUI;windowPref -remove bboxPivotUI;

 

 

0 Likes
Message 5 of 16

andymc4997
Advocate
Advocate

Hi damaggio,

 

Gosh, I suppose I should have looked around Bonus Tools more thoroughly, my bad :(. This will at least make it a little easier, and I do like how you can position the pivot to Min and Max locations from the pop up box. But I'm with you on the scripting side. I'm a graphic artist/designer who walks sideways from the weight of my right brain, so, Lol. 

 

Thanks! 

0 Likes
Message 6 of 16

andymc4997
Advocate
Advocate

To just be clear however... what I would LOVE to happen is that I simply type in my Width Height and Depth figures and BAM, the object sits on the origin lined up to it's base. 

0 Likes
Message 7 of 16

mspeer
Consultant
Consultant

Hi!

I would be glad if i had more time to do a tutorial on this.

But as a hint: The pivot is not the problem, the pivot of a new object is at ground-level, so there is no need to move it.

0 Likes
Message 8 of 16

andymc4997
Advocate
Advocate

The pivot is at the ground level? It certainly isn't for me, unless I'm just missing something right in front of me. For example, when I create a poly cube, the pivot is in the center, and the object is placed at the origin like so:

 

Capture.JPG

 

I would like for it to be like this:

 

Capture.JPG

0 Likes
Message 9 of 16

mspeer
Consultant
Consultant

Hi!

 

The pivot is at [0 0 0] that's ground level, Y=0.

0 Likes
Message 10 of 16

andymc4997
Advocate
Advocate

Hi,

 

Perhaps then I didn't make myself clear. I want the base of the object AND the pivot to be at the ground level. 

0 Likes
Message 11 of 16

mspeer
Consultant
Consultant

Hi!

You made it clear, but as said before currently i only have time for this short hint.

0 Likes
Message 12 of 16

andymc4997
Advocate
Advocate

Ok, completely understood. Time is in short supply.

0 Likes
Message 13 of 16

mb28
Explorer
Explorer

You can use the following script to move the pivot to the bottom of your model. The MEL script centers the pivot, then grabs the bounding box for your selection and re-applies the centered pivot from X and Z while putting the lowest bounds of your object's bounding box into the Y portion of the pivot.  Enjoy!

 

float $bb[];
float $pivots[];

// center pivot on object
xform -ws -a -cp;
// store bounding box info into float array
$bb = `xform -q -ws -a -bb`;
//store centered pivots into pivot float array
$pivots = `xform -q -ws -a -piv`;
// set new pivots, X, Z from centered pivot, Y from lower bounding box
xform -ws -a -piv $pivots[0] $bb[1] $pivots[2];
Message 14 of 16

FlorianDubiel
Contributor
Contributor

awesome, after 20 years I found it 🙂 My new Shortcut  Alt+p !!

0 Likes
Message 15 of 16

Labyrinth_Visual
Explorer
Explorer

@mb28 Is there a way to tweak this so that it does the same thing to a range of objects at once?  I'm trying to do this for thousands of cards 😬

0 Likes
Message 16 of 16

hein101254
Community Visitor
Community Visitor

Hello everyone, I found this entry after I created my own "multi object solution" to this theme. I hope you've finished your cards by now. Nevertheless, I'm sending you my script. Maybe someone can use it....

 

{

// https://www.hein-liessem.de
string $sel[] = `ls -sl`;

    for($i=0; $i < size($sel); $i++)
    {
    //print($sel[$i]+"\n");
    string $currentObj=$sel[$i];

    select($currentObj);
   CenterPivot;
   FreezeTransformations;

   float $oldpos[] = `getAttr $currentObj.rotatePivot`;
   float $Min[] = `getAttr ($currentObj + ".boundingBoxMin")`;
   float $Max[] = `getAttr ($currentObj + ".boundingBoxMax")`;
   float $sum[];

   $sum[1]=(($Max[1])-($Min[1]));
   $sum[1]= $sum[1]/2;

   xform -os -piv $oldpos[0] $Min[1] $oldpos[2] $currentObj;

   }
}

 

The curly brackets at the beginning and the end of the script prevent the "redeclaration error"

 

Have fun....

0 Likes