Home Technical Talk

setting pivot to z=0?

sir-knight
polycounter lvl 10
Offline / Send Message
sir-knight polycounter lvl 10
hey folks, is there a quick and painless method for setting the pivot of any object to it's lowest z value?

I have to export a ton of objects where the bottom of the mesh must be at Z=0 and there's got to be a quicker way of doing it rather than by hand.

Replies

  • Rob Galanakis
    for s in selection do
    	s.pivot = [s.pivot.x, s.pivot.y, s.min.z]
    

    That will move the pivot in each selected object down to 0 in the Z. Do you want to move the actual mesh? That is a bit more complicated.

    Edit: Doesn't seem to be working. Will look into it more when I get some time tonight. Not sure why .min isn't returning the expected result (I thought it was the min of the AABB, maybe not).
  • sir-knight
    Offline / Send Message
    sir-knight polycounter lvl 10
    I want to move the pivot to the lowest point on the mesh,so when I move the mesh to 0,0,0 for export, the bottom of the mesh lines up with any ground plane set that z=0 that the developers are testing with.
  • rube
    Offline / Send Message
    rube polycounter lvl 17
    This is how I'd do it in maya, so maybe it works the same way in max... but probably not

    select all the objects, hit insert to go into move pivot mode, hold x (snap to grid) and click on the Z part of the pivot manipulator and drag it to 0.. that'll snap them all on the z axis only. but I have no idea if you can just do the same thing in max.

    EDIT: I just saw your next post, ignore what I just said
  • Mark Dygert
    Sounds like something that's easily scriptable.

    Jim Jagger wrote a script to move the pivot down to the lowest point in a mesh, its called Base Pivot, its part of his giant pack of scripts.
    http://www.jimjagger.com/Pages/Home/Index.htm

    Then if you want to move the object to the world zero point use

    $.pos = [0,0,0]
  • sir-knight
    Offline / Send Message
    sir-knight polycounter lvl 10
    doh, 404s on all the files
  • Mark Dygert
    Ahh crap... I think you can get the script if you follow the links from the main page. If you don't want to bother heres the code he uses:
    for i in selection do (i.pivot = i.min)
    
    It doesn't center the pivot, but instead sets the piviot to XYZ 0 which is down in the left corner of the mesh...

    But Prof's method works for me if I switch s with i.
    S must mean something to 3dsmax?
    This should get you going.
    (
    ResetPivot $
    CenterPivot $
     for i in selection do 
         (
        i.pivot = [i.pivot.x, i.pivot.y, i.min.z]
        )         
    $.pos = [0,0,0]
    )
    
  • sir-knight
    Offline / Send Message
    sir-knight polycounter lvl 10
    ah perfect thanks vig and prof, I really should learn how max scripting works :P I used Jim's tools and tweaked his script with your bit of code, minus the $.pos = [0,0,0], works like a dream :D
Sign In or Register to comment.