cmds.select('ctrl_A', add=True)
cmds.select('ctrl_B', add=True)
master_helper = cmds.curve(
name="masterParent", degree = 1,
point = [(-0.5, 0.5, 0.5), (0.5, 0.5, 0.5), (0.5, 0.5, -0.5),
(-0.5, 0.5, -0.5), (-0.5, 0.5, 0.5), (-0.5, -0.5, 0.5),
(-0.5, -0.5, -0.5), (0.5, -0.5, -0.5), (0.5, -0.5, 0.5),
(-0.5, -0.5, 0.5), (0.5, -0.5, 0.5), (0.5, 0.5, 0.5),
(0.5, 0.5, -0.5), (0.5, -0.5, -0.5), (-0.5, -0.5, -0.5),
(-0.5, 0.5, -0.5)]
)
boundingBox = cmds.exactWorldBoundingBox(selections)
scaleX = abs(boundingBox[0] - boundingBox[3])
scaleY = abs(boundingBox[1] - boundingBox[4])
scaleZ = abs(boundingBox[2] - boundingBox[5])
cmds.xform(master_helper, scale=[scaleX, scaleY, scaleZ])
count = len(selections)
sums = [0,0,0]
for item in selections:
pos = cmds.xform(item, q=True, rp=True, ws=True)
sums[0] += pos[0]
sums[1] += pos[1]
sums[2] += pos[2]
center = [sums[0]/count, sums[1]/count, sums[2]/count]
cmds.move(center[0], center[1], center[2], master_helper)
cmds.makeIdentity(master_helper, apply=True, translate=True, rotate=True, scale=True)
cmds.parent('ctrl_A', master_helper)
cmds.parent('ctrl_B', master_helper)