;553500’]@
Here is an example from a post script to create custom spaces in the rig build process/rig file:
#CREATE SPACES FOR WEAPONS ANIMS
pairs = "weapon_l_anim", "driver_hand_l"], "weapon_r_anim", "driver_hand_r"]]
for pair in pairs:
control = pair[0]
spaceObj = pair[1]
spaceSwitchFollow = control + "_space_switcher_follow"
spaceSwitchNode = control + "_space_switcher"
#add attr to the space switcher node
cmds.select(spaceSwitchNode)
cmds.addAttr(ln = "space_" + spaceObj, minValue = 0, maxValue = 1, dv = 0, keyable = True)
#add constraint to the new object on the follow node
constraint = cmds.parentConstraint(spaceObj, spaceSwitchFollow, mo = True)[0]
#hook up connections
targets = cmds.parentConstraint(constraint, q = True, targetList = True)
weight = 0
for i in range(int(len(targets))):
if targets*.find(spaceObj) != -1:
weight = i
cmds.connectAttr(spaceSwitchNode + ".space_" + spaceObj, constraint + "." + spaceObj + "W" + str(weight))
#lockNode on space object so it cannot be deleted by the user (if node is not a referenced node)
if spaceObj.find(":") == -1:
cmds.lockNode(spaceObj)