Equally Distribute Objects
24 March 2024
Usually used it in redistributing joints between a start and end point.
There is Modify>Snap Align Objects
but it doesn't seem to work on multi-axis.
# The last two objects selected will be the parent start and parent end
import maya.cmds as cmds
joint_list = cmds.ls(sl=True)
children_list = joint_list[:-2]
parent_list = joint_list[-2:]
count = len(children_list)
steps = 1.0 / (count+1)
perc = 0
print (children_list)
print (parent_list)
for child in children_list:
perc += steps
print (perc)
constraint = cmds.parentConstraint(parent_list[0], child, weight=1.0 - perc)[0]
cmds.parentConstraint(parent_list[1], child, weight=perc)
cmds.delete(constraint )