This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import maya.cmds as cmds | |
sel = cmds.ls(selection=True, type="transform") | |
for obj in sel: | |
# get current world position of pivot | |
pivot = cmds.xform(obj, q=True, ws=True, rp=True) # rotate pivot = transform origin | |
# calculate offset needed to move pivot to (0,0,0) | |
offset = [-pivot[0], -pivot[1], -pivot[2]] | |
# move the object by that offset | |
cmds.move(offset[0], offset[1], offset[2], obj, r=True, ws=True) |