Skip to content

Instantly share code, notes, and snippets.

@tpoveda
Last active June 19, 2018 09:00
Show Gist options
  • Save tpoveda/fba8c32e23cd2044bab5137e7a7653a9 to your computer and use it in GitHub Desktop.
Save tpoveda/fba8c32e23cd2044bab5137e7a7653a9 to your computer and use it in GitHub Desktop.
Snap source object pivot position to the world position of the target object
import maya.cmds as cmds
def snap_pivot(source=None, target=None):
sel = cmds.ls(sl=True)
source = sel[0] if not source else source
target = sel[1] if not target else target
pivot = cmds.xform(target, query=True, pivots=True, worldSpace=True)
cmds.xform(source, worldSpace=True, pivots=(pivot[0], pivot[1], pivot[2]))
snap_pivot()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment