Skip to content

Instantly share code, notes, and snippets.

@mclavan
Last active August 29, 2015 14:08
Show Gist options
  • Save mclavan/5aa41a2f8b007be2e10d to your computer and use it in GitHub Desktop.
Save mclavan/5aa41a2f8b007be2e10d to your computer and use it in GitHub Desktop.
Copy Pivot Tool - PyMel
'''
Copy Pivot
by TELIMS
How to Work:
Select object with pivot you want to change too.
Select object who's pivot you want to change.
If selecting multiple objects, the first selected object will
be the pivot that all other object's pivots move to.
run:
import telims_copy_pivot
reload(telims_copy_pivot)
telims_copy_pivot.copy_pivot()
'''
# import pymel.core
import pymel.core as pm
print "Telims's Copy Pivot Tool"
print ""
def copy_pivot():
# get the number of objects selected
selected = pm.ls(selection=True)
# error and warning checking
if len(selected) < 2:
pm.error("You have not selected 2 or more objects...")
elif len(selected) > 2:
pm.warning("You have selected more than 2 objects, all object's pivot points will be changed to first selected object")
else:
print "Pivot is being copied..."
print ""
print "Pivot has been copied"
# retainer
count = 1
while count < len(selected):
# get position of pivot
position = selected[0].getRotatePivot(worldSpace=True)
print 'Rotate Plane Pivot: {0}'.format(position)
# position = pm.xform(selected[0], q=True, worldSpace=True, rotatePivot=True,)
# change pivot
# pm.xform(selected[count], piv=[position[0], position[1], position[2]], ws=True,)
selected[count].setPivots(position, ws=True)
# retainer
count = count + 1
copy_pivot()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment