Search code examples
pythonmayamelpymel

Center Pivot without xform


Is there a way to center the pivot of an object without the use of xform?

I really would like to try and find a pyMel version of this, or the maya api, as xform is generally 10x slower than a pymel or api solution.

Obviously you can achieve it with xform like so:

xform(obj, cp=1)

But I'm trying to find another way, does anyone know anything?


Solution

  • Would you like to find a PyMEL version? Or an object oriented way of doing this? xform(obj, cp=1) is within PyMEL. However the object oriented method to produce the same result is quite similar to theodox's response in which you would do the following:

    obj.setScalePivot(obj.c.get())
    obj.setRotatePivot(obj.c.get())
    

    Centering an objects pivot is based on the center of the bounding box. obj.c.get will return to you just that. Just plug that into the methods above.