This script allows you to copy object pivot translation and rotation from one object to another one.
How to use:
- copy code to the script editor "Python tab"
- select source object
- select target object
- execute script
Works on multiple selection. Align all object pivots with last selected.
- copy code to the script editor "Python tab"
- select source object
- select target object
- execute script
Works on multiple selection. Align all object pivots with last selected.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | ''' Align pivots by Serge Scherbakov. Usage: 1. Select source object(s) 2. Add to selection target object 3. Run script by 'import copyPivot\n copyPivot.copyPivot() ''' import maya.cmds as cmds import maya.mel as mel def copyPivot (): sourceObj = cmds.ls(sl = True)[len(cmds.ls(sl = True))-1] targetObj = cmds.ls(sl = True)[0:(len(cmds.ls(sl = True))-1)] parentList = [] for obj in targetObj: if cmds.listRelatives( obj, parent = True): parentList.append(cmds.listRelatives( obj, parent = True)[0]) else: parentList.append('') if len(cmds.ls(sl = True))<2: cmds.error('select 2 or more objects.') pivotTranslate = cmds.xform (sourceObj, q = True, ws = True, rotatePivot = True) cmds.parent(targetObj, sourceObj) cmds.makeIdentity(targetObj, a = True, t = True, r = True, s = True) cmds.xform (targetObj, ws = True, pivots = pivotTranslate) for ind in range(len(targetObj)): if parentList[ind] != '' : cmds.parent(targetObj[ind], parentList[ind]) else: cmds.parent(targetObj[ind], world = True) copyPivot() |
thankyou very much Great Tool!
ReplyDeleteThanks a lot, realy helpful!
ReplyDeleteT H A N K Y O U !!!!!!!
ReplyDeleteWhy this is not part of Maya is beyond me! Thank you SOOOOOOOO much!!!!!!!!
ReplyDeleteIt's actually part of Maya since 2016/2017...Modify -> match transform -> match pivots
DeleteMATCH PIVOTS IN MAYA DOES NOT MATCH THE ROTATION.
DeleteLove your tutorials. A class mate showed me them and they where incredible helpful.
ReplyDeleteThank you so much.
ReplyDeleteawesome thank you!
ReplyDeleteVery helpful. Thank you.
ReplyDeleteThxxxx :D
ReplyDeleteBelow is faster for complicate hierarchy.
ReplyDelete1) select object to snap TO and then display>transform display>rotation pivot
2) select the object to be snapped and then just v-snap to the rotation pivot in step one
https://simplymaya.com/forum/showthread.php?t=33926
anyone else getting a syntax error when running?
ReplyDeletei keep getting this Error: Line 4.16: Syntax error
i have no experience with MEL, any help would be great.
thanks
Hello,
ReplyDeleteMake sure you paste it in a Python tab of the Script Editor.
Cheers
Life saver, thanks
ReplyDeleteHi, script is very handy,
ReplyDeletebut is it possible to make it works correctly on object with complicated hierarchy?
In my case I get error with "wrong syntax", but if I unparent objects- it works like a charm.
СПАСИБО!!!
ReplyDelete