Moving a selected object to another object pivot point using script


#1

moving a selected object to another object pivot point using script

So the idea is to select a object then run a script then select a another object in the outliner and have to move to its pivot point
is there a way to do this?

I hope this makes sense
Let me know if you have any questions or require any more info

any help will be appreciated


#2

This should do it. Select the object first that you want to move the pivot, then shift select the object with the target pivot and run the script. It’s for python.

def move_pivot_to_target():
    if not cmds.ls(sl=1):
        return
    elif len(cmds.ls(sl=1)) != 2:
        return

    child_sel, target_sel = cmds.ls(sl=1)
    target_piv = cmds.xform(target_sel, q=1, rp=1)
    cmds.move(target_piv[0], target_piv[1],target_piv[2], '{0}.scalePivot'.format(child_sel), a=1)
    cmds.move(target_piv[0], target_piv[1],target_piv[2], '{0}.rotatePivot'.format(child_sel), a=1)

move_pivot_to_target()

#3

Wow thanks a mil man