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!!!!!!!!
ReplyDeleteLove your tutorials. A class mate showed me them and they where incredible helpful.
ReplyDeleteThank you so much.
ReplyDeleteawesome thank you!
ReplyDelete