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?

有帮助吗?

解决方案

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.

其他提示

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top