Center Pivot without xform

7.7k Views Asked by At

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?

2

There are 2 best solutions below

12
On BEST ANSWER

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.

4
On

In the API it would be calling mfnTransform.setRotatePivotTranslation and setScalePivotTranslation with 'balance' turned on. There's not enough overhead to warrant a workaround - it's hard to see how this could be a bottleneck.