How to use:
- Select the object to contrain
- SHIFT+Select all the object that must constrain the first one
- Execute the script
On the target object there's a new attribute called "parentTo" and you can select from list. Now I'm trying to resolve the snap problem and create a simple pyQt interface...
This is the base script you can add to the Shelf
_________________________________________________
import maya.cmds as cmds
attrString = ''
selection = cmds.ls (sl=True)
target = selection[0]
l = len(selection)
for i in range(1,l):
cmds.group(em=True, n = 'grp_' + selection[i])
cmds.select('grp_' + selection[i],selection[i])
cmds.parent()
cmds.select('grp_' + selection[i],target)
cmds.parentConstraint(mo=True, weight=1)
cmds.select(cl=True)
attrString += selection[i] + ':'
cmds.select(target, r=True)
cmds.addAttr(ln='parentTo', at='enum', en = attrString, k=True, h = False)
expreString =''
for j in range (0,l-1):
expreString += expreString + 'if (' + target + '.parentTo == '+ str(j) + '){'
for i in range(1,l):
if (i == (j+1)):
expreString += target + '_parentConstraint1.' + 'grp_' + selection[i] + 'W' + str(i-1) + '= 1;'
else:
expreString += target + '_parentConstraint1.' + 'grp_' + selection[i] + 'W' + str(i-1) + '= 0;'
expreString += '};'
k += 1
cmds.expression(s = expreString)
_________________________________________________
Comments
Post a Comment