def matchSkinWeightsTofirstCV(source, transforms): '''Takes the weights on the source object and matches them to all the transforms Args: source (pm.nt.NurbsCV): source transform with nurbsCurve shape to get weights from transforms (pm.nt.Transform): transforms that have nurbsCurve shapes under them (will not work with meshes) Returns: (boolean): True if success Usage: matchSkinWeightsTofirstCV(pm.ls(sl=True)[-1], pm.ls(sl=True)[:-1]) ''' cv_SC = lib_skin.SkinCluster(transform=source) for xform in transforms: cv = lib_crv.getNearestCV(source, xform) weights = cv_SC.getWeightsAtIndex(cv.currentItemIndex()) xform_SC = lib_skin.SkinCluster(transform=xform) xform_SC.setWeightsAtIndex(0, weights) return True
def copyCVWeightToCurve(source, transforms): '''Copies the weight from the closest CV on the source curve to the given transform (has to be skinned) Args: source (pm.nt.NurbsCV): source transform with nurbsCurve shape to get weights from transforms (pm.nt.Transform): transforms that have curves under them (will not work with meshes) Returns: (boolean): True if success Usage: copyCVWeightToCurve(pm.ls(sl=True)[-1], pm.ls(sl=True)[:-1]) ''' cv_SC = lib_skin.SkinCluster(transform=source) for xform in transforms: cv = lib_crv.getNearestCV(source, xform) weights = cv_SC.getWeightsAtIndex(cv.currentItemIndex()) xform_SC = lib_skin.SkinCluster(transform=xform) for xform_CV in xform.cv[:]: xform_SC.setWeightsAtIndex(xform_CV.currentItemIndex(), weights) return True