本文整理汇总了Python中maya.cmds.parentConstraint函数的典型用法代码示例。如果您正苦于以下问题:Python parentConstraint函数的具体用法?Python parentConstraint怎么用?Python parentConstraint使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parentConstraint函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addNoiseOnControl
def addNoiseOnControl(Object, Control):
if Object.__class__ == list:
pass
elif Object.__class__ in [str, unicode]:
Object = [Object]
else:
"Not Valid Arguments on Add Noise"
return None
Expresion = """//{0}
{0}.rotateX=`noise((time+{2})*{1}.frequency)`*{1}.amplitud;
{0}.rotateY=`noise((time+{2}+30)*{1}.frequency)`*{1}.amplitud;
{0}.rotateZ=`noise((time+{2}+60)*{1}.frequency)`*{1}.amplitud;
{0}.ty=`noise((time+{2}+90)*{1}.frequency)`*{1}.movY + {1}.movY;
"""
if not isNoiseControl(Control):
addAttributes(Control)
for eachObject in Object:
constraints = constraintComponents(gessFrom=eachObject)
ResetGroup = RMRigTools.RMCreateGroupOnObj(eachObject, Type="child")
for eachkey in constraints.constraintDic:
cmds.delete(eachkey)
cmds.parentConstraint(ResetGroup, constraints.constraintDic[eachkey]["affected"], mo=True)
ExpressionNode = cmds.expression(
name="NoiseMainExpresion", string=Expresion.format(ResetGroup, Control, random.uniform(0, 100))
)
示例2: create_spine_rig
def create_spine_rig(base_curve, rig_region_name, pelvis, cog, spine_1, spine_2, spine_3, spine_4, neck):
# create group to contain all rigging nodes
cmds.select(cl=True)
spine_group = cmds.group(em=True, n=rig_region_name + '_group')
cmds.select(spine_group, base_curve, r=True)
cmds.parent()
# add the arm group node to the base curve rig nodes attr
add_node_to_rig_nodes(base_curve, rig_region_name, spine_group)
cog_curve, cog_curve_group = jt_ctl_curve.create(cog, 'star_5', lock_unused=False)
cmds.setAttr(cog_curve + '.scale', 3,3,3)
cmds.select(cog_curve, r=True)
cmds.makeIdentity(apply=True, t=0, r=0, s=1, n=0)
cmds.select(cog_curve, cog, r=True)
cmds.parentConstraint(mo=True, weight=1)
cmds.scaleConstraint(mo=True, weight=1)
cmds.select(cog_curve_group, base_curve, r=True)
cmds.parent()
pelvis_curve, pelvis_curve_group = jt_ctl_curve.create(pelvis, 'waist', True, True, True, True)
spine_1_curve, spine_1_curve_group = jt_ctl_curve.create(spine_1, 'circle', True, True, True, True)
spine_2_curve, spine_2_curve_group = jt_ctl_curve.create(spine_2, 'circle', True, True, True, True)
spine_3_curve, spine_3_curve_group = jt_ctl_curve.create(spine_3, 'circle', True, True, True, True)
spine_4_curve, spine_4_curve_group = jt_ctl_curve.create(spine_4, 'circle', True, True, True, True)
neck_curve, neck_curve_group = jt_ctl_curve.create(neck, 'circle', True, True, True, True)
# parent fk controlls to spine group
cmds.select(cog_curve_group, pelvis_curve_group, spine_1_curve_group, spine_2_curve_group, spine_3_curve_group, spine_4_curve_group, neck_curve_group, spine_group, r=True)
cmds.parent()
示例3: keyToOn
def keyToOn():
controller = mc.ls(sl=True)[0]
channelBox = mel.eval('global string $gChannelBoxName; $temp=$gChannelBoxName;') #fetch maya's main channelbox
attrs = mc.channelBox(channelBox, q=True, sma=True)
if attrs:
channel = controller + "." + attrs[0]
constraint = mc.listConnections(channel, type="constraint")[0]
currentTime = mc.currentTime( query=True )
# save rest pose on constraint
# mc.currentTime(currentTime-1)
constraintChannels = mc.listConnections(constraint, type="animCurve")
mc.parentConstraint(controller, constraint, edit=True, maintainOffset=True)
for i in constraintChannels:
value = mc.getAttr(mc.listConnections(i, plugs=True)[0])
setKeyframe(mc.listConnections(i, plugs=True)[0], currentTime, value)
# set key on 1 for controller
setKeyframe(channel, currentTime-1, value=0)
setKeyframe(channel, currentTime, value=1)
# mc.currentTime( currentTime )
else:
mc.warning("Select constrain channel!")
示例4: BindSkeletons
def BindSkeletons(source, dest, method='connect'):
'''
From 2 given root joints search through each hierarchy for child joints, match
them based on node name, then connect their trans/rots directly, or
parentConstrain them. Again cmds for speed
'''
sourceJoints = cmds.listRelatives(source, ad=True, f=True, type='joint')
destJoints = cmds.listRelatives(dest, ad=True, f=True, type='joint')
if cmds.nodeType(source) == 'joint':
sourceJoints.append(source)
if cmds.nodeType(dest) == 'joint':
destJoints.append(dest)
attrs = ['rotateX', 'rotateY', 'rotateZ', 'translateX', 'translateY', 'translateZ']
for sJnt, dJnt in MatchGivenHierarchys(sourceJoints, destJoints):
if method == 'connect':
for attr in attrs:
try:
cmds.connectAttr('%s.%s' % (sJnt, attr), '%s.%s' % (dJnt, attr), f=True)
except:
pass
elif method == 'constrain':
try:
cmds.parentConstraint(sJnt, dJnt, mo=True)
except:
pass
示例5: addJoint
def addJoint(side='L'):
if mc.objExists('%s_armPalm_bnd_0'%side):return
# make joint and locators
Joint = mc.createNode('joint', name='%s_armPalm_bnd_0'%side)
JointGroup = mc.group(Joint, name='%s_armPalm_bndgrp_0'%side)
FKloc = mc.spaceLocator(p=(0,0,0), name='%s_armPalmFK_loc_0'%side)[0]
IKloc = mc.spaceLocator(p=(0,0,0), name='%s_armPalmIK_loc_0'%side)[0]
# constraint
constraintNode = mc.parentConstraint(FKloc, IKloc, JointGroup)
# match position
mc.delete(mc.parentConstraint('%s_armMiddleAIK_jnt_0'%side, FKloc))
mc.delete(mc.parentConstraint('%s_armMiddleAIK_jnt_0'%side, IKloc))
# parent locator
mc.parent(FKloc, '%s_armWristFk_jnt_0'%side)
mc.parent(IKloc, '%s_armMiddleAIK_jnt_0'%side)
# make ikfk switch
reverseNode = [x.split('.')[0] for x in mc.connectionInfo('%s_armFkIk_ctl_0.FKIKBlend'%side, dfs=True) if mc.nodeType(x.split('.')[0])=='reverse'][0]
mc.connectAttr('%s.outputX'%reverseNode, '%s.%sW0'%(constraintNode[0], FKloc))
mc.connectAttr('%s_armFkIk_ctl_0.FKIKBlend'%side, '%s.%sW1'%(constraintNode[0], IKloc))
# add to bind set
mc.sets(Joint, e=True, forceElement='bind_joints_set')
# connect jointLayer
mc.connectAttr('jointLayer.drawInfo', '%s.drawOverride'%Joint)
# parent joint
mc.parent(JointGroup, '%s_armBind_org_0'%side)
示例6: cameraFrustum_build
def cameraFrustum_build(cam_shape):
#make sure a camera is loaded
if cam_shape==0:
cmds.error('no camera loaded...select a camera and load')
else:
#create frustum only if one doesnt already exist
selCamXform = cmds.listRelatives(cam_shape[0], p=1)
prefix = 'frust_'
frustumGrpName = prefix + 'camera_frustum_all_grp'
if cmds.objExists(frustumGrpName)==0:
#create main grp
frustumMainGrp = cmds.group(em=1, n=frustumGrpName);
cmds.setAttr(frustumGrpName + '.tx', lock=1, keyable=0, channelBox=0)
cmds.setAttr(frustumGrpName + '.ty', lock=1, keyable=0, channelBox=0)
cmds.setAttr(frustumGrpName + '.tz', lock=1, keyable=0, channelBox=0)
cmds.setAttr(frustumGrpName + '.rx', lock=1, keyable=0, channelBox=0)
cmds.setAttr(frustumGrpName + '.ry', lock=1, keyable=0, channelBox=0)
cmds.setAttr(frustumGrpName + '.rz', lock=1, keyable=0, channelBox=0)
cmds.setAttr(frustumGrpName + '.sx', lock=1, keyable=0, channelBox=0)
cmds.setAttr(frustumGrpName + '.sy', lock=1, keyable=0, channelBox=0)
cmds.setAttr(frustumGrpName + '.sz', lock=1, keyable=0, channelBox=0)
cmds.setAttr(frustumGrpName + '.v', lock=1, keyable=0, channelBox=0)
#create frustum geo
frustumGeo = cmds.polyCube(w=2, h=2, d=2, n=prefix + 'camera_frustum_geo')
cmds.delete(frustumGeo[0], constructionHistory=True)
cmds.parent(frustumGeo[0], frustumMainGrp)
#load plugin "nearestPointOnMesh.mll" if needed and connect
plugin = cmds.pluginInfo('nearestPointOnMesh.mll', q=1, l=1)
if plugin==0:
cmds.loadPlugin('nearestPointOnMesh.mll')
nearNodeName = prefix + 'npomNode'
npomNode = cmds.createNode('nearestPointOnMesh', n=nearNodeName)
cmds.connectAttr(frustumGeo[0] + '.worldMesh', npomNode + '.inMesh')
#create clusters
cmds.select(frustumGeo[0] + '.vtx[4:7]', r=1)
nearCluster = cmds.cluster(n=prefix + 'camera_nearFrustum_cluster')
cmds.select(frustumGeo[0] + '.vtx[0:3]', r=1)
farCluster = cmds.cluster(n=prefix + 'camera_farFrustum_cluster')
#create near/far/camera locs
cameraLoc = cmds.spaceLocator(p=(0, 0, 0), n=prefix + 'camera_loc')
cmds.parent(cameraLoc[0], frustumMainGrp)
nearLoc = cmds.spaceLocator(p=(0, 0, 0), n=prefix + 'camera_nearFrustum_loc')
cmds.move(0, 0, -1)
farLoc = cmds.spaceLocator(p=(0, 0, 0), n=prefix + 'camera_farFrustum_loc')
cmds.move(0, 0, 1)
#parent clusters under loc -- parent locs under camera loc
cmds.parent(nearCluster[1], nearLoc[0])
cmds.parent(farCluster[1], farLoc[0])
cmds.parent(nearLoc[0], cameraLoc[0])
cmds.parent(farLoc[0], cameraLoc[0])
#constrain camera loc to camera
cmds.parentConstraint(selCamXform, cameraLoc, weight=1)
return frustumGeo[0]
示例7: locatorOnly
def locatorOnly(self):
sel = cmds.ls(sl=True)
# Gives error if more than one object is selected.
if len(sel) > 1:
cmds.error("Too many objects selected!")
# Creates and snaps a locator to object.
elif len(sel):
tObj = sel[0]
tLoc = "{0}_tLoc".format(tObj)
LScale = cmds.floatField(LocScale, q=True, v=True)
if cmds.objExists(tLoc):
cmds.delete(tLoc)
cmds.spaceLocator(n="{0}_tLoc".format(tObj))
cmds.scale(LScale, LScale, LScale)
cmds.parentConstraint(tObj, tLoc, mo=False)
cmds.parentConstraint(tObj, tLoc, rm=True)
print LScale
# Gives error if no objects are selected.
else:
cmds.error("No objects selected!")
示例8: rigBlendControl
def rigBlendControl(self, _parent):
# Move and parent blend control
rc.orientControl(self.m_blendControl, _parent)
group = rg.addGroup(self.m_blendControl, "%s_0" %(self.m_blendControl))
moveValue = -2
if self.m_isMirrored:
moveValue *= -1
cmds.setAttr("%s.t%s" %(self.m_blendControl, self.m_twistAxis), moveValue)
cmds.parentConstraint(_parent, group, mo=1)
rc.lockAttrs(
self.m_blendControl,
[
"tx",
"ty",
"tz",
"rx",
"ry",
"rz",
"sx",
"sy",
"sz",
"visibility"
],
True,
True
)
示例9: create_ik_setup
def create_ik_setup(self):
"""Creates the IK setup."""
ik = cmds.ikHandle(sj=self.result_jnts[0], ee=self.result_jnts[-1], sol='ikSplineSolver', ns=1)
cmds.rename(ik[1], '%s_%s_%s' % (self.side, 'neck', self.nc.effector))
curve = cmds.rename(ik[2], '%s_%s_%s' % (self.side, 'neck', self.nc.curve))
cmds.setAttr('%s.inheritsTransform' % curve, 0)
ik = cmds.rename(ik[0], '%s_%s_%s' % (self.side, 'neck', self.nc.ikhandle))
cmds.select(self.additional_jnts, curve)
cmds.skinCluster(tsb=True)
cmds.parent(ik, self.top_grp)
cmds.setAttr('%s.dTwistControlEnable' % ik, 1)
cmds.setAttr('%s.dWorldUpType' % ik, 4)
cmds.setAttr('%s.dWorldUpAxis' % ik, 4)
cmds.setAttr('%s.dWorldUpVectorY' % ik, -1)
cmds.setAttr('%s.dWorldUpVectorEndY' % ik, 1)
cmds.setAttr('%s.dWorldUpVectorEndZ' % ik, -1)
cmds.connectAttr('%s.worldMatrix[0]' % self.additional_jnts[0], '%s.dWorldUpMatrix' % ik, f=True)
cmds.connectAttr('%s.worldMatrix[0]' % self.additional_jnts[1], '%s.dWorldUpMatrixEnd' % ik, f=True)
self.head_grp = cmds.group(self.controls['head'])
self.head_grp = cmds.rename(self.head_grp, '%s_head_CTL_%s' % (self.side, self.nc.group))
cmds.parent(self.head_grp, self.top_grp)
self.c.move_pivot_to(self.guides['neckEnd'][0], self.guides['neckEnd'][1], self.guides['neckEnd'][2], self.head_grp)
cmds.parentConstraint(self.controls['head'], self.additional_jnts[-1], mo=True, weight=1)
cmds.orientConstraint(self.controls['head_rot'], self.result_jnts[-1], mo=True, weight=1)
示例10: AddSpaceObject
def AddSpaceObject(self, ControlObject, SpaceObject, SpaceSwitchName = "spaceSwitch"):
SpaceSwDic = self.GetSpaceSwitchDic( ControlObject, SpaceSwitchName = SpaceSwitchName)
EnumDic = self.AddEnumParameters([self.NameConv.RMGetAShortName(SpaceObject)],ControlObject)
Switch = cmds.shadingNode('condition', asUtility=True, name = SpaceSwitchName + "SWCondition")
cmds.connectAttr(ControlObject + "." + SpaceSwitchName, Switch + ".firstTerm")
cmds.setAttr (Switch +".secondTerm", EnumDic[self.NameConv.RMGetAShortName(SpaceObject)])
cmds.setAttr (Switch +".operation", 0)
cmds.setAttr (Switch +".colorIfTrueR", 1)
cmds.setAttr (Switch +".colorIfFalseR", 0)
if self.NameConv.RMIsNameInFormat(ControlObject):
Switch = self.NameConv.RMRenameBasedOnBaseName(ControlObject, Switch, NewName = Switch)
else:
Switch = self.NameConv.RMRenameNameInFormat(Switch)
for eachConstraint in SpaceSwDic['constraints']:
Object = SpaceSwDic['constraints'][eachConstraint]['object']
parentConstraint = cmds.parentConstraint (SpaceObject, Object, mo = True)
WA = cmds.parentConstraint (parentConstraint, q = True, weightAliasList = True)
TL = cmds.parentConstraint (parentConstraint, q = True, targetList = True)
if SpaceObject in TL:
cmds.connectAttr (Switch + ".outColorR", parentConstraint[0] + "." + WA[TL.index(SpaceObject)])
else:
print "Error, cant find spaceobject in constraint targetList"
示例11: getParentConstraintDic
def getParentConstraintDic (self, parentConstraint) :
returnedDic = {'alias':{}, "object":None }
aliasDic={}
if cmds.objectType(parentConstraint)=="parentConstraint":
WA = cmds.parentConstraint (parentConstraint, q = True, weightAliasList = True)
TL = cmds.parentConstraint (parentConstraint, q = True, targetList = True)
elif cmds.objectType(parentConstraint)=="orientConstraint":
WA = cmds.orientConstraint (parentConstraint, q = True, weightAliasList = True)
TL = cmds.orientConstraint (parentConstraint, q = True, targetList = True)
elif cmds.objectType(parentConstraint)=="pointConstraint":
WA = cmds.pointConstraint (parentConstraint, q = True, weightAliasList = True)
TL = cmds.pointConstraint (parentConstraint, q = True, targetList = True)
else:
"error No constraint Type identified"
if len(WA) == len(TL):
for eachWAIndex in range(0,len(WA)):
aliasDic[WA[eachWAIndex]] = TL[eachWAIndex]
returnedDic["object"] = cmds.listConnections(parentConstraint + ".constraintRotateX")[0]
returnedDic["alias"] = aliasDic
return returnedDic
示例12: closestPointOnModel
def closestPointOnModel(self , modelShape , obj):
closest_Point = []
modelShapeType = self.getObjType(modelShape)
temp = mc.createNode('transform',name=obj+'_point_temp')
mc.parentConstraint(obj,temp,mo = False)
#model type data
if modelShapeType == 'kNurbsSurface':
closest_Point = ['closestPointOnSurface' , temp+'_cpos' , 'local' , 'inputSurface']
elif modelShapeType == 'kMesh':
closest_Point = ['closestPointOnMesh' , temp+'_cpom' , 'outMesh' , 'inMesh']
#create getUV Node
closest_PointNode = mc.createNode( closest_Point[0] , name = closest_Point[1] )
mc.connectAttr( temp+'.translate' , closest_PointNode+'.inPosition' )
mc.connectAttr( modelShape + '.' + closest_Point[2] , closest_PointNode +'.' + closest_Point[3] )
#get UV
U = mc.getAttr(closest_PointNode + '.result.parameterU')
V = mc.getAttr(closest_PointNode + '.result.parameterV')
mc.delete(closest_PointNode,temp)
return {'u':U , 'v':V}
示例13: RMCreateTwist
def RMCreateTwist(self, TwistJoint, LookAtObject, NumberOfTB = 3, LookAtAxis = "Y"):
#LookAtObject = cmds.listRelatives( TwistJoint,type = "transform",children=True)[]
positionA = cmds.xform(TwistJoint ,q=True,ws=True,rp=True)
positionB = cmds.xform(LookAtObject ,q=True,ws=True,rp=True)
vectorA = om.MVector(positionA)
vectorB = om.MVector(positionB)
self.RMCreateBonesBetweenPoints(vectorA,vectorB,NumberOfTB, AlignObject = TwistJoint)
Distance = RMRigTools.RMPointDistance( TwistJoint, LookAtObject)
cmds.parentConstraint (TwistJoint,self.TwistResetJoints)
resetPoint , control = RMRigShapeControls.RMCreateBoxCtrl(self.TwistJoints[0], Xratio = .1, Yratio = .1, Zratio = .1, customSize = Distance/5 ,name = "TwistOrigin" + self.NameConv.RMGetAShortName (TwistJoint).title())
#control = self.NameConv.RMRenameBasedOnBaseName(TwistJoint , control, NewName = self.NameConv.RMGetAShortName(control))
#resetPoint = self.NameConv.RMRenameBasedOnBaseName(TwistJoint , resetPoint, NewName = self.NameConv.RMGetAShortName(resetPoint))
sign = 1
MoveDistance = Distance/5
if "-" in LookAtAxis:
sign = -1
if "Z" in LookAtAxis or "z" in LookAtAxis:
MoveList = [0,0, MoveDistance * sign]
WUV = [0,0,sign]
elif "Y" in LookAtAxis or "y" in LookAtAxis:
MoveList = [0,MoveDistance * sign,0 ]
WUV = [0,sign,0]
cmds.xform( resetPoint, os = True, relative=True, t = MoveList)
cmds.aimConstraint( LookAtObject,self.TwistJoints[0], aim = [1,0,0], worldUpVector = [0,0,1], worldUpType = "object", worldUpObject = control)
TwistJointDivide = cmds.shadingNode( "multiplyDivide", asUtility = True, name = "TwistJoint" + self.NameConv.RMGetAShortName( TwistJoint).title())
TwistJointDivide = self.NameConv.RMRenameBasedOnBaseName( TwistJoint , TwistJointDivide, NewName = self.NameConv.RMGetAShortName( TwistJointDivide))
TwistAddition = cmds.shadingNode( "plusMinusAverage", asUtility = True, name = "TwistJointAdd" + self.NameConv.RMGetAShortName( TwistJoint).title())
TwistAddition = self.NameConv.RMRenameBasedOnBaseName( TwistJoint , TwistAddition, NewName = self.NameConv.RMGetAShortName( TwistAddition))
NegativeLookAtRotation = cmds.shadingNode( "multiplyDivide", asUtility = True, name = "NegativeLookAtRotation" + self.NameConv.RMGetAShortName( TwistJoint).title())
NegativeLookAtRotation = self.NameConv.RMRenameBasedOnBaseName( TwistJoint , NegativeLookAtRotation, NewName = self.NameConv.RMGetAShortName( NegativeLookAtRotation))
cmds.connectAttr( LookAtObject + ".rotateX", NegativeLookAtRotation + ".input1X")
cmds.setAttr(NegativeLookAtRotation + ".input2X", -1 )
cmds.setAttr(NegativeLookAtRotation + ".operation", 1 )
cmds.connectAttr(self.TwistJoints[0]+".rotateX", TwistAddition + ".input1D[0]")
cmds.connectAttr( NegativeLookAtRotation + ".outputX", TwistAddition + ".input1D[1]")
cmds.connectAttr(TwistAddition + ".output1D", TwistJointDivide + ".input1X")
#cmds.connectAttr(self.TwistJoints[0]+".rotateX", TwistJointDivide + ".input1X") in this case the rotation of the lookatNode was not affecting
cmds.setAttr(TwistJointDivide + ".input2X", -(len(self.TwistJoints) - 1))
cmds.setAttr(TwistJointDivide + ".operation", 2 )
for eachJoint in self.TwistJoints[1:]:
cmds.connectAttr(TwistJointDivide+".outputX", eachJoint + ".rotateX")
self.TwistControlResetPoint = resetPoint
self.TwistControl = control
示例14: createArmSwitches
def createArmSwitches(pairs, instance):
parents = []
enumvals = []
connodes = []
for p in range(len(pairs)):
parents.append(pairs[p][0])
con = cmds.shadingNode("condition", asUtility=True, n=instance + pairs[p][0] + 'Switch_CON')
connodes.append(con)
cmds.setAttr(con+'.secondTerm', p)
enumvals.append(pairs[p][2])
ctrlparent = cmds.listRelatives(pairs[0][1], p=True)[0]
switchgrpname = pairs[0][1].replace('_GRP', '_SWITCH' )
sgrp = cmds.group(n=switchgrpname, em=True)
tc = cmds.parentConstraint(pairs[0][1], sgrp, mo=False)
cmds.delete(tc)
cmds.parent(sgrp, ctrlparent)
cmds.parent(pairs[0][1], sgrp)
parentcon = cmds.parentConstraint(parents[0], parents[1], parents[2], parents[3], parents[4], sgrp, mo=True)
cmds.addAttr(pairs[p][2], at='enum', en="World:Root:COG:Pelvis:Chest:", shortName="switch", longName="switch", k=True)
for c in range(len(connodes)):
cmds.setAttr(connodes[c]+'.colorIfTrueR', 1)
cmds.setAttr(connodes[c]+'.colorIfTrueG', 1)
cmds.setAttr(connodes[c]+'.colorIfTrueB', 1)
cmds.setAttr(connodes[c]+'.colorIfFalseR', 0)
cmds.setAttr(connodes[c]+'.colorIfFalseG', 0)
cmds.setAttr(connodes[c]+'.colorIfFalseB', 0)
cmds.connectAttr(pairs[0][2]+'.switch', connodes[c]+'.firstTerm')
cmds.connectAttr(connodes[c]+'.outColorR', parentcon[0] + '.' + pairs[c][0] + 'W' + str(c))
示例15: RMRedistributeConstraint
def RMRedistributeConstraint(self,ListOfDrivers, ListOfConstrained, MaxInfluences, KeepBorders = True, ConstraintType = "parent"):
DeltaMaxInfluence = 1/(float (len(ListOfDrivers))-1)
CentersControlDic = {}
for i in range (0,len( ListOfDrivers)):
CentersControlDic[ListOfDrivers[i]] = ( DeltaMaxInfluence*i)
pprint.pprint (CentersControlDic)
DeltaPositionConstrained = float(1/(float(len(ListOfConstrained))-1))
PositionConstDic = {}
for i in range(0,len( ListOfConstrained)):
PositionConstDic[ListOfConstrained[i]] = (DeltaPositionConstrained*i)
pprint.pprint (PositionConstDic)
reach = MaxInfluences * DeltaMaxInfluence
for eachConstrained in ListOfConstrained:
for eachDriver in ListOfDrivers:
weight = self.RMGaussCosine( PositionConstDic [ eachConstrained ], CentersControlDic [ eachDriver ], reach )
if weight > 0:
if ConstraintType == "parent":
cmds.parentConstraint(eachDriver, eachConstrained , weight = weight,mo = True)
elif ConstraintType == "point":
cmds.pointConstraint(eachDriver, eachConstrained , weight = weight,mo = True)
elif ConstraintType == "orient":
cmds.orientConstraint(eachDriver, eachConstrained , weight = weight,mo = True)
else:
print "not valid costraintType requested, valid types are point, parent, or orient"