def generate(self): # Duplicate Objects for i in range(0, self.layerAmount + 1): self.objsToCombine.append(cmds.duplicate(self.obj)) # Vertex Painting for i in range(0, self.layerAmount + 1): paintObj = self.objsToCombine[i][0] paintColor = [i * self.furStep, 0, 0, 1] self.__obj_vertex_painting(paintObj, paintColor, i) # Combine selected objects for o in self.objsToCombine: cmds.select(o, add=True) combinedObj = cmds.polyUnite()[0] mel.eval("cleanUpScene 3") # clean up the scene unused objects cmds.delete(ch=True) # remove history # set parent back after combined objParent = cmds.listRelatives(self.obj, parent=True) cmds.parent(combinedObj, objParent) # Find the Root Joint in the scene rig = self.__findRoot("joint") # Bind Skin and Joint self.__bind_skin_to_joint(rig, combinedObj) # Copy Skin Weight through skin cluster sourceCluster = self.__get_skin_cluster_from_mesh(self.obj) targetCluster = self.__get_skin_cluster_from_mesh(combinedObj) cmds.copySkinWeights(ss=sourceCluster, ds=targetCluster, noMirror=True) cmds.delete(self.obj) # rename object cmds.rename(combinedObj, self.obj)
def maya_copyskinweights(self,base,target): infs = self.getinfluenceObjects(base) if infs: cmds.select(infs,target) cmds.skinCluster(toSelectedBones=1,maximumInfluences=5,dropoffRate=4,name=target+"_skinCluster") cmds.copySkinWeights(base,target,surfaceAssociation = "closestPoint",influenceAssociation= ["oneToOne","closestJoint","closestBone"],noMirror = True)
def skin_copy_many(): '마지막에 선택한 skinWeight 값을 모두 copy한다.' #선택 명령 sels = cmds.ls(sl=1, fl=1) #기존 skin cluster 저장 sel_skin = sels[-1] sel_skin_cluster = mel.eval('findRelatedSkinCluster(\"' + sel_skin + '\")') if '.vtx' in sels[0]: vtx_sets = cmds.sets(sels[0:-1], n='skinCopy_vtx_sets') cmds.copySkinWeights(sel_skin, vtx_sets, nm=True, sa='closestPoint', ia='closestJoint') cmds.delete(vtx_sets) else: for sel in sels[0:-1]: grp_sels = cmds.listRelatives(sel, ad=1, pa=True, typ='shape') for grp_sel in grp_sels: skin_cluster = mel.eval('findRelatedSkinCluster(\"' + grp_sel + '\")') if skin_cluster: cmds.copySkinWeights(ss=sel_skin_cluster, ds=skin_cluster, nm=True, sa='closestPoint', ia='closestJoint') else: pass
def copyWeight(first, second): hists = cmds.listHistory(first, pdo=1) skinNode = None for hist in hists: if cmds.nodeType(hist) == 'skinCluster': skinNode = hist if not skinNode: return None targetSkinNode = None targetHists = cmds.listHistory(second, pdo=1) if targetHists: for hist in targetHists: if cmds.nodeType(hist) == 'skinCluster': targetSkinNode = hist if not targetSkinNode: bindObjs = cmds.listConnections(skinNode + '.matrix', s=1, d=0, type='joint') bindObjs.append(second) print bindObjs cmds.skinCluster(bindObjs) cmds.copySkinWeights(first, second, noMirror=True, surfaceAssociation='closestPoint', influenceAssociation='oneToOne')
def copySkinComponents(source, destinationVerts): if not mc.listRelatives(source, shapes=True): raise RuntimeError('Source object must be geometry.') sourceSkin = utl.getSkinCluster(source) if not sourceSkin: raise RuntimeError("Source mesh doesn't have a skinCluster to copy from.") destMesh = mc.ls(destinationVerts[0], o=True)[0] destMesh = mc.listRelatives(destMesh, parent=True)[0] destSkin = copySkinInfluences(source, destMesh) tempSet = mc.sets(destinationVerts) mc.select(source, tempSet) mc.copySkinWeights(noMirror=True, surfaceAssociation='closestPoint', influenceAssociation='closestJoint', normalize=True) mc.delete(tempSet) mc.select(destinationVerts)
def stepTwo(): global weightPointPosList weightPointPos=[[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0],[0.0,0.0,0.0]] for n in range(10): weightPointPos[n]=mc.xform('weightPlane.vtx[%d]'%n,q=1,os=1,t=1) weightPointPosList= weightPointPos weights=[1.0,1.0,0.5,0.0,0.0,1.0,1.0,0.5,0.0,0.0] RootJoint=mc.joint(None,p=[-1,0,0],n='RootJoint') weightJoint=mc.joint(None,p=[1,0,0],n='weightJoint') mc.skinCluster([weightPlane,RootJoint,weightJoint],nw=1,maximumInfluences=1,dropoffRate=0.1,n='weightSkinCluster') for i in range(10): mc.skinPercent('weightSkinCluster','weightPlane.vtx[%d]'%i,tv=[weightJoint,weights[i]]) mc.duplicate(faceObj,n='skinFace') mc.scale(1,1,0,'skinFace',p=pos) mc.skinCluster(['skinFace',RootJoint,weightJoint],nw=1,maximumInfluences=1,dropoffRate=0.1,n='skinFaceSkinCluster') mc.copySkinWeights( ss='weightSkinCluster', ds='skinFaceSkinCluster', noMirror=True ,surfaceAssociation='closestPoint',influenceAssociation='oneToOne') faceVtxNum=mc.polyEvaluate(faceObj,v=1) for n in range(faceVtxNum): BSWeight=mc.skinPercent('skinFaceSkinCluster','skinFace.vtx[%d]'%n,q=1,t=weightJoint,v=1) for target in targetObjs: TarVtxPos=mc.xform(target+'.vtx[%d]'%n,q=1,os=1,t=1) SouVtxPos=mc.xform(faceObj+'.vtx[%d]'%n,q=1,os=1,t=1) MoveVector=[(SouVtxPos[0]-TarVtxPos[0])*(1-BSWeight),(SouVtxPos[1]-TarVtxPos[1])*(1-BSWeight),(SouVtxPos[2]-TarVtxPos[2])*(1-BSWeight)] mc.xform(target+'.vtx[%d]'%n,r=1,t=MoveVector) mc.delete(['weightPlane','RootJoint','weightJoint','skinFace']) mc.deleteUI('splitStepTwoWin')
def copySkinComponents(source, destinationVerts): if not mc.listRelatives(source, shapes=True): raise RuntimeError('Source object must be geometry.') sourceSkin = getSkinCluster(source) if not sourceSkin: raise RuntimeError( "Source mesh doesn't have a skinCluster to copy from.") destMesh = mc.ls(destinationVerts[0], o=True)[0] destMesh = mc.listRelatives(destMesh, parent=True)[0] destSkin = copySkinInfluences(source, destMesh) tempSet = mc.sets(destinationVerts) mc.select(source, tempSet) mc.copySkinWeights(noMirror=True, surfaceAssociation='closestPoint', influenceAssociation='closestJoint', normalize=True) mc.delete(tempSet) mc.select(destinationVerts)
def ezSymWeight(self, target, mirror=False): cmds.select(target, r=True) cmds.copySkinWeights(mirrorMode='YZ', mirrorInverse=mirror, surfaceAssociation='closestPoint', influenceAssociation='label', normalize=False)
def transfer_skin(source, target): """Transfer the skinning from source object to target object""" src_geom = source src_skin = mel.eval('findRelatedSkinCluster("{}")'.format(src_geom)) if src_skin: src_infs = cmds.skinCluster(src_skin, query=True, influence=True) tgt_geom = target tgt_skin = mel.eval('findRelatedSkinCluster("{}")'.format(tgt_geom)) if tgt_skin: cmds.delete(tgt_skin) tgt_skin = cmds.skinCluster(src_infs, tgt_geom, name=tgt_geom + '_skinCluster', toSelectedBones=True)[0] cmds.copySkinWeights(sourceSkin=src_skin, destinationSkin=tgt_skin, surfaceAssociation='closestPoint', influenceAssociation='oneToOne', noMirror=True, smooth=False) LOG.info('Successfully transferred skinning from {} to {}'.format( source, target)) else: LOG.error('No skinCluster found on {}'.format(source)) return
def copyWeight( first, second ): hists = cmds.listHistory( first, pdo=1 ) skinNode = None for hist in hists: if cmds.nodeType( hist ) == 'skinCluster': skinNode = hist if not skinNode: return None targetSkinNode = None targetHists = cmds.listHistory( second, pdo=1 ) if targetHists: for hist in targetHists: if cmds.nodeType( hist ) == 'skinCluster': targetSkinNode = hist if not targetSkinNode: bindObjs = cmds.listConnections( skinNode+'.matrix', s=1, d=0, type='joint' ) bindObjs.append( second ) print bindObjs cmds.skinCluster( bindObjs, tsb=1 ) cmds.copySkinWeights( first, second, noMirror=True, surfaceAssociation='closestPoint', influenceAssociation ='oneToOne' )
def copySkinning(*args): """select the orig bound mesh, then the new unbound target mesh and run""" sel = cmds.ls(sl=True) orig = sel[0] target = sel[1] #get orig obj joints try: jnts = cmds.skinCluster(orig, q=True, influence = True) except: cmds.warning("couldn't get skin weights from {}".format(orig)) #bind the target with the jnts try: targetClus = cmds.skinCluster(jnts, target, bindMethod=0, skinMethod=0, normalizeWeights=1, maximumInfluences = 3, obeyMaxInfluences=False, tsb=True)[0] print targetClus except: cmds.warning("couln't bind to {}".format(target)) #get skin clusters origClus = mel.eval("findRelatedSkinCluster " + orig) #copy skin weights from orig to target try: cmds.copySkinWeights(ss=origClus, ds=targetClus, noMirror=True, sa="closestPoint", ia="closestJoint") except: cmds.warning("couldn't copy skin weights from {0} to {1}".format(orig, target))
def dpCopySkin(self, sourceItem, destinationList, skinInfList, *args): """ Do the copy skin from sourceItem to destinationList using the skinInfList. """ for item in destinationList: # get correct naming skinClusterName = utils.extractSuffix(item) if "|" in skinClusterName: skinClusterName = skinClusterName[skinClusterName.rfind("|") + 1:] # create skinCluster node cmds.skinCluster(skinInfList, item, name=skinClusterName + "_SC", toSelectedBones=True, maximumInfluences=3, skinMethod=0) cmds.select(sourceItem) cmds.select(item, toggle=True) # copy skin weights from sourceItem to item node cmds.copySkinWeights( noMirror=True, surfaceAssociation="closestPoint", influenceAssociation=["label", "oneToOne", "closestJoint"]) # log result print self.langDic[ self.langName]['i083_copiedSkin'], sourceItem, item
def xfer(srcGeom, dstGeom, smooth=False, uv=False, rui=False): srcSkin = mel.eval('findRelatedSkinCluster("' + srcGeom + '")') if cmds.objExists(srcSkin): srcInfs = cmds.skinCluster(srcSkin, q=True, inf=True) dstSkin = mel.eval('findRelatedSkinCluster("' + dstGeom + '")') if dstSkin: cmds.delete(dstSkin) dstSkin = cmds.skinCluster(srcInfs, dstGeom, n=dstGeom + '_skinCluster', tsb=True)[0] cmds.copySkinWeights(ss=srcSkin, ds=dstSkin, sa='closestPoint', ia='oneToOne', nm=True, sm=smooth) cmds.connectAttr(srcSkin + '.skinningMethod', dstSkin + '.skinningMethod', f=True) cmds.disconnectAttr(srcSkin + '.skinningMethod', dstSkin + '.skinningMethod') return (dstSkin) else: return (None)
def skinAs(src, dst, smooth=False): ''' ''' # Check inputs if not mc.objExists(src): raise Exception('Source object "' + src + '" does not exist!') if not mc.objExists(dst): raise Exception('Destination object "' + dst + '" does not exist!') # Get source skinCluster srcSkin = findRelatedSkinCluster(src) # Check destination skinCluster dstSkin = findRelatedSkinCluster(dst) # Build destination skinCluster if not dstSkin: srcInfList = mc.skinCluster(srcSkin, q=True, inf=True) dstSkin = mc.skinCluster(srcInfList, dst, rui=False, n=dst + '_skinCluster')[0] # Copy skin weights mc.copySkinWeights(ss=str(srcSkin), ds=str(dstSkin), noMirror=True, sm=smooth) # Return result return dstSkin
def xferSkin(sourceObject="", targetObjects=""): selectedObjects = cmds.ls(selection=True) if len(selectedObjects) < 2: cmds.error("must be at least 2 skined objects selected") if sourceObject == "": sourceObject = selectedObjects[0] if targetObjects == "": targetObjects = selectedObjects[1:] sourceSkinClusterNode = ka_skinCluster.findRelatedSkinCluster(sourceObject) sourceSkinInfluenceList = getSkinInfluences(sourceObject) for each in targetObjects: cmds.skinCluster(sourceSkinInfluenceList, each, removeUnusedInfluence=False) targetSkinClusterNode = ka_skinCluster.findRelatedSkinCluster(each) cmds.copySkinWeights(sourceSkin=sourceSkinClusterNode, destinationSkin=targetSkinClusterNode, noMirror=True, influenceAssociation='oneToOne', surfaceAssociation='closestPoint') cmds.select(targetObjects, replace=True)
def copy_proxy_to_skin(src_mesh=None, dst_mesh=None): """Copy skinning information from source (proxy) to destination mesh :param src_mesh: Source mesh :param dst_mesh: Destination Mesh :return: New skinCluster """ # Test for selection if not src_mesh or not dst_mesh: meshes = cmds.ls(sl=1) if len(meshes) == 2: src_mesh = meshes[0] dst_mesh = meshes[1] else: raise RuntimeError("You need to have TWO meshes selected!") # Get source skinCluster src_skin = cmds.ls(cmds.listHistory(src_mesh), type='skinCluster') if not src_skin: raise RuntimeError("{} does not have a skinCluster".format(src_skin)) # Check destination skinCluster dst_skin = cmds.ls(cmds.listHistory(dst_mesh), type='skinCluster') # Save current pose influence_list = cmds.skinCluster(src_skin, q=True, wi=True) cur_pose = cmds.dagPose(influence_list, save=True, name='skinToPose') # Go to bind pose before copying weights bind_pose = cmds.dagPose(influence_list, q=True, bindPose=True) if bind_pose: cmds.dagPose(bind_pose[0], restore=True) # Build destination skinCluster if not dst_skin: dst_prefix = dst_mesh.split(':')[-1] src_influence_list = cmds.skinCluster(src_skin[0], q=True, inf=True) dst_skin = cmds.skinCluster(src_influence_list, dst_mesh, toSelectedBones=True, rui=False, n=dst_prefix + '_skinCluster') # Copy skin weights cmds.copySkinWeights(sourceSkin=str(src_skin[0]), destinationSkin=str(dst_skin[0]), surfaceAssociation='closestPoint', influenceAssociation='name', noMirror=True) cmds.dagPose(cur_pose, restore=True) cmds.delete(cur_pose) cmds.select(cl=1) # Return result return dst_skin
def mirrorSkinWeights(mesh=None, skin=None, *args): skin = getMeshSkinCluster(mesh) if not skin else skin if skin: cmds.copySkinWeights(ss=skin, ds=skin, mirrorMode='YZ', surfaceAssociation='closestPoint', influenceAssociation='oneToOne', ) return
def mirrorPosNeg(self,*args): """ Expects components to be selected """ sel = cmds.ls(sl=True,fl=True) try: skClstr = mel.eval( 'findRelatedSkinCluster("%s");'%sel[0].split('.')[0] ) except: raise Exception('Could not get a skinCluster for selected: ',sel[0].split('.')[0]) # Inverse: - to + cmds.copySkinWeights( ss=skClstr, ds=skClstr, mirrorMode='YZ', mirrorInverse=False )
def main(): selection = cmds.ls(sl=True) if not selection or len(selection) <= 1: cmds.error('Must select a source and a destination skin.') #要英語訳の確認 shapes = cmds.listRelatives(selection[0], s=True, pa=True) if not shapes: cmds.error('Node not have shape.') #要英語訳の確認 srcSkinCluster = cmds.listConnections(shapes[0] + '.inMesh', s=True, d=False) if not srcSkinCluster: cmds.error( 'Please select node of skin cluster has been applied.') #要英語訳の確認 srcSkinCluster = srcSkinCluster[0] skinningMethod = cmds.getAttr(srcSkinCluster + '.skm') dropoffRate = cmds.getAttr(srcSkinCluster + '.dr') maintainMaxInfluences = cmds.getAttr(srcSkinCluster + '.mmi') maxInfluences = cmds.getAttr(srcSkinCluster + '.mi') bindMethod = cmds.getAttr(srcSkinCluster + '.bm') normalizeWeights = cmds.getAttr(srcSkinCluster + '.nw') influences = cmds.skinCluster(srcSkinCluster, q=True, inf=True) for dst in selection[1:]: shapes = cmds.listRelatives(dst, s=True, pa=True, type='mesh') if not shapes: continue dstSkinCluster = cmds.listConnections(shapes[0] + '.inMesh', s=True, d=False) if not dstSkinCluster: dstSkinCluster = cmds.skinCluster( dst, influences, omi=maintainMaxInfluences, mi=maxInfluences, dr=dropoffRate, sm=skinningMethod, nw=normalizeWeights, tsb=True, ) dstSkinCluster = dstSkinCluster[0] cmds.copySkinWeights( ss=srcSkinCluster, ds=dstSkinCluster, surfaceAssociation='closestPoint', influenceAssociation=['name', 'closestJoint', 'oneToOne'], normalize=True, noMirror=True) print 'Transfar skin weight ' + selection[0] + '>' + dst
def transferSkinweight(sourceMesh=None, targetMeshList=None): '''copy skinweight between geos, clear out existed skinClusters on targets ''' sourceMesh = sourceMesh or mc.ls(sl=True)[0] # an mesh targetMeshList = targetMeshList or mc.ls(sl=True)[1:] # a list of meshes mc.select(cl=True) #get skinCluster from sourceMesh skinNodeSource = pm.mel.findRelatedSkinCluster(sourceMesh) #query max influence number and influence joints maxInf = mc.skinCluster(skinNodeSource, q=True, maximumInfluences=True) joints = mc.skinCluster(skinNodeSource, q=True, inf=True) #loop through the targeMeshes skinNodeTargetList = [] for targetMesh in targetMeshList: #if sourceMesh already bound, unbind it and clean up non deform history(tweaks node) if pm.mel.findRelatedSkinCluster(targetMesh): mc.skinCluster(targetMesh, e=True, ub=True) mc.select(targetMesh) pm.mel.doBakeNonDefHistory(1, ["prePost"]) #delete non deform history mc.select(cl=True) #bind new skin skinNodeTarget = mc.skinCluster( joints, targetMesh, mi=maxInf, #maximumInfluences omi=False, #obeyMaxInfluences tsb=True, #toSelectedBones bm=0, #bindMethod sm=0, #skinMethod nw=1, #normalizeWeights wd=0, #weightDistribution rui=False, #removeUnusedInfluence dr=4, #dropoffRate ihs=False #includeHiddenSelections )[0] mc.select(cl=True) #perform copy skin weight mc.copySkinWeights( sourceSkin=skinNodeSource, destinationSkin=skinNodeTarget, surfaceAssociation='closestPoint', influenceAssociation=['oneToOne', 'closestJoint', 'closestBone'], noMirror=True, #noMirror=False >> mirror skinweight mode normalize=False) skinNodeTargetList.append(skinNodeTarget) sys.stdout.write('skinweight transferred!\n') return skinNodeSource, skinNodeTargetList
def bindLike(srcObj, dstObj): srcSkinCls = getSkinClusterNode(srcObj) srcJoints = cmds.listConnections(srcSkinCls + ".matrix", type="joint") cmds.select(srcJoints) dstSkinCls = cmds.skinCluster(srcJoints, dstObj, tsb=1)[0] cmds.copySkinWeights( sourceSkin=srcSkinCls, noMirror=1, destinationSkin=dstSkinCls, surfaceAssociation="closestPoint", influenceAssociation="oneToOne", )
def copySkinedMesh(self): rootRjt = self.namespace + 'Spline0_RJT' rootBjtCheck = cmds.listConnections(rootRjt + '.r', s=0, d=1, type='joint') if not rootBjtCheck: return None rootBjt = rootBjtCheck[0] bjts = cmds.listRelatives(rootBjt, c=1, ad=1) bjts.append(rootBjt) meshs = rigbase.getSkinedMeshByJnt(bjts) duMeshs = [] neadJnts = cmds.ls(self.namespace + '*_MOC*', type='joint') for neadJnt in neadJnts: self.moveToParentPoseLittle(neadJnt) for mesh in meshs: meshSkinCl = rigbase.getHistory(mesh, 'skinCluster')[0] cmds.setAttr(meshSkinCl + '.envelope', 0) duMesh = cmds.duplicate(mesh)[0] duMeshs.append(duMesh) rigbase.cleanMesh(duMesh) bindObjs = [] bindObjs += neadJnts bindObjs.append(duMesh) cmds.skinCluster(bindObjs, mi=3, tsb=1) cmds.setAttr(meshSkinCl + '.envelope', 1) cmds.undoInfo(swf=0) if duMeshs: cmds.select(duMeshs) mel.eval('removeUnusedInfluences') for i in range(len(meshs)): cmds.copySkinWeights(meshs[i], duMeshs[i], noMirror=1, sa='closestPoint', ia='closestBone', normalize=1) cmds.undoInfo(swf=1) try: cmds.parent(cmds.group(duMeshs, n='MocMesh_GRP'), w=1) mel.eval("sets -e -forceElement initialShadingGroup;") cmds.select(duMeshs) except: pass
def mirrorSkinCluster( targets, inverse = False ): if len( sels ) == 1: srcSkin = sgCmds.getNodeFromHistory( sels[0], 'skinCluster' )[0] dstSkin = srcSkin elif len( sels ) == 2: srcSkin = sgCmds.getNodeFromHistory( sels[0], 'skinCluster' )[0] dstSkin = sgCmds.getNodeFromHistory( sels[1], 'skinCluster' )[0] else: return None cmds.copySkinWeights( ss=srcSkin.name(), ds=dstSkin.name(), mirrorMode='YZ', surfaceAssociation = 'closestPoint', influenceAssociation=['oneToOne','closestJoint'], mirrorInverse=inverse )
def skinAs(source=None, target=None, sel=True): ''' copies across the skin cluster and weights from a source mesh to a target mesh can work on selection - ensure that source is selected first, followed by target mesh ''' if sel: source, target = cmds.ls(sl=True, l=True) elif not cmds.objExists(source) and not cmds.objExists(target): print "No valid geometry selected - try again" return False source_shp = cmds.listRelatives(source, s=True, ni=True) target_shp = cmds.listRelatives(target, s=True, ni=True) # find the skin cluster on the mesh his = cmds.listHistory(source_shp, pdo=True) skin = False for node in his: if cmds.nodeType(node) == "skinCluster": skin = node # skin = cmds.listConnections(source_shp, type="skinCluster" ) if skin: joints = cmds.skinCluster(skin, q=True, inf=True) else: print "source mesh does not have a skinCluster to copy" return False if joints and source_shp and target_shp: new_skin = cmds.skinCluster(joints, target, tsb=True, sm=1, nw=1) source_UV = cmds.polyUVSet(source, q=True, auv=True) target_UV = cmds.polyUVSet(target, q=True, auv=True) if source_UV == target_UV: # if UV sets match, copy across using the UV maps - get a better result for transfer from low to high res meshes cmds.copySkinWeights(ss=skin, ds=new_skin[0], sa="closestPoint", nm=True, nr=True, uv=[source_UV[0], target_UV[0]]) else: # else do a standard weight copy cmds.copySkinWeights(ss=skin, ds=new_skin[0], sa="closestPoint", nr=True, nm=True) print "skin weights copied from %s to %s" % (source, target) return True else: print "copying skin weights failed - check your source and target mesh selections" return False
def assignSkc(skc, target): shapeHistory = cmds.listHistory(target, lv=3) oldSkc = cmds.ls(shapeHistory, typ='skinCluster') if oldSkc: cmds.delete(oldSkc) jnt = cmds.skinCluster(skc, weightedInfluence=True, q=True) newSkc = cmds.skinCluster(jnt, target) cmds.copySkinWeights(ss=skc[0], ds=newSkc[0], nm=True, surfaceAssociation='closestPoint') cmds.rename(newSkc, skc[0]) return newSkc
def skop(): essel = mc.textScrollList('nt_texList', q=1, ai=1) ellam = mc.ls(sl=1) for oro in ellam: try: mc.skinCluster(essel, oro, tsb=1) except: pass mc.select(melons.eval("textField -q -tx meshth"), r=1) mc.select(oro, add=1) mc.copySkinWeights(sa="closestPoint", ia=("name", "label", "oneToOne"), nm=1)
def copySkin(sel): if sel: source = sel[0] dest = sel[1:] for d in dest: cmds.copySkinWeights(source, d, noMirror=True, surfaceAssociation='closestPoint', influenceAssociation='oneToOne') cmds.select(sel[1:]) mel.eval('removeUnusedInfluences')
def massCopySkinWeightsGo(): ''' select all destGeos, shift-select srcGeo, run ''' sel = mc.ls(os=True) destGeos = sel[:-1] srcGeo = sel[-1] srcSkn = meval('findRelatedSkinCluster %s' % srcGeo) for geo in destGeos: destSkn = meval('findRelatedSkinCluster %s' % geo) mc.copySkinWeights(ss=srcSkn, ds=destSkn, ia='oneToOne', sa='closestPoint', nm=1)
def copySkinCluster(source, destination): sourceSkin = utl.getSkinCluster(source) if not sourceSkin: raise RuntimeError("Source mesh doesn't have a skinCluster to copy from.") destSkin = copySkinInfluences(source, destination) mc.copySkinWeights(sourceSkin=sourceSkin, destinationSkin=destSkin, noMirror=True, surfaceAssociation='closestPoint', influenceAssociation='closestJoint', normalize=True) return destSkin
def copySkinning(*args): """ select the orig bound mesh, then the new unbound target(s) mesh and run Args: None Return: None """ sel = cmds.ls(sl=True) if sel and len(sel) > 1: orig = sel[0] targets = sel[1:] for target in targets: #get orig obj joints try: jnts = cmds.skinCluster(orig, q=True, influence=True) except Exception, e: cmds.warning( "rigFuncs.copySkinning: --------Couldn't get skin weights from {0}\n{1}" .format(orig, e)) #bind the target with the jnts try: targetClus = cmds.skinCluster(jnts, target, bindMethod=0, skinMethod=0, normalizeWeights=1, maximumInfluences=3, obeyMaxInfluences=False, tsb=True)[0] print targetClus except Exception, e: cmds.warning( "rigFuncs.copySkinning: --------Couldn't bind to {0}\n{1}". format(target, e)) origClus = mel.eval("findRelatedSkinCluster " + orig) #copy skin weights from orig to target try: cmds.copySkinWeights(ss=origClus, ds=targetClus, noMirror=True, sa="closestPoint", ia="closestJoint") except Exception, e: cmds.warning( "rigFuncs.copySkinning: --------Couldn't copy skin weights from {0} to {1}\n{2}" .format(orig, target, e))
def SK_copyWeightToOtherObj(): objs = rig.ls(sl=True) if objs: sourObj = objs[0] skinClusterS = SK_getSkinCluster(sourObj) for obj in objs: if obj != sourObj: skinClusterT = SK_getSkinCluster(obj) if skinClusterT: rig.copySkinWeights(ss=skinClusterS, ds=skinClusterT, noMirror=True, surfaceAssociation='closestPoint', influenceAssociation='closestJoint')
def copySkinToSelectedGeo(): """ Copy skin weights to multiple destinations. Uses the last selected as the source. """ sel = cmds.ls(sl=1) for each in sel[:-1]: dest = skinFn.getSkinInfo(each)[0] source = skinFn.getSkinInfo(sel[-1])[0] cmds.copySkinWeights(ds=dest, ss=source, noMirror=1, surfaceAssociation='closestPoint', influenceAssociation='closestJoint') return True
def copy_skin_weights(source_skin="", target_skin=""): """ copy the skin weights from one to another. :param source_skin: <str> the source skin cluster. :param target_skin: <str> the destination skin cluster. :return: <bool> True for success. """ cmds.copySkinWeights(sourceSkin=source_skin, destinationSkin=target_skin, noMirror=True, surfaceAssociation="closestComponent", influenceAssociation=["closestJoint", "oneToOne", "label"], normalize=True) return True
def transfer_weights(source_skin=None, selection=None): """ Transfers weights from a given source_skin object to a given selection. :param source_skin: source_skin object to copy the weights from :param selection: Selection of geo objects to transfer the weights to :return: """ if source_skin and selection: for destination_skin in selection: cmds.copySkinWeights(sourceSkin=source_skin, noMirror=True, destinationSkin=destination_skin)
def replaceMeshSkin(): sel = cmds.ls(sl=True) if len(sel) == 2: obj = {} obj["source"] = sel[0] obj["dest"] = sel[1] joints = cmds.skinCluster(obj["source"], q=True, inf=True) cmds.select(obj["dest"], joints) cmds.skinCluster(tsb=True, mi=4) cmds.select(obj["source"], obj["dest"]) cmds.copySkinWeights() cmds.delete(obj["source"]) elif len(sel) != 2: print "Must select only 2 objects"
def weightToL( *args ): sels = cmds.ls( sl=1 ) targetObj = sels[0] hists = cmds.listHistory( targetObj ) skinNode = '' for hist in hists: if cmds.nodeType( hist ) == 'skinCluster': skinNode = hist break if not skinNode: return None cmds.copySkinWeights( ss=skinNode, ds=skinNode, mirrorMode = 'YZ', mirrorInverse=True, surfaceAssociation = 'closestPoint', influenceAssociation = ['oneToOne','closestJoint'] )
def transferSkinWeights(oldGeo, newGeo): ''' creates skinCluster and copy weights for newGeo return new skinCluster ''' # get bound joints used for oldGeo bnJnts = mc.skinCluster(oldGeo, q=1, inf=1) # get skin cluster used for oldGeo oldSc = meval('findRelatedSkinCluster %s' % oldGeo) # create new skin cluster on newGeo, using same bound joints newSc = mc.skinCluster(bnJnts, newGeo, tsb=True)[0] # copy weights mc.copySkinWeights(ss=oldSc, ds=newSc, ia='oneToOne', sa='closestPoint', nm=1) return newSc
def copyWeights(fromList, toList): #filterString = textField.text() #print filterString if fromList.count() > 0: for fromIndex in xrange(fromList.count()): fromMesh = fromList.item(fromIndex).text() print "From Mesh: ", fromMesh if toList.count() > 0: for toIndex in xrange(toList.count()): toMesh = toList.item(toIndex).text() if fromMesh.lower() in toMesh.lower(): print "Matched To Mesh found: ", toMesh print "Copying weights from ", fromMesh, " to ", toMesh toCluster = findCluster(toMesh) fromCluster = findCluster(fromMesh) cmds.copySkinWeights(ss=fromCluster, ds=toCluster, noMirror=True, surfaceAssociation="closestPoint", influenceAssociation=["closestJoint", "oneToOne", "name"]) else: cmds.warning("Your Copy TO list is empty.") else: cmds.warning("Your Copy FROM list is empty.")
def copySkinWeight(self,WeightObj,copyWeightObj,delCopyObjSkin): if cmds.objExists(WeightObj) == True: if mel.eval("findRelatedSkinCluster" +"(\""+ WeightObj +"\")") != "": copyWeightObjSkin = mel.eval("findRelatedSkinCluster" +"(\""+ copyWeightObj +"\")") if copyWeightObjSkin != "" and cmds.nodeType(copyWeightObjSkin) and delCopyObjSkin == 'yes': cmds.delete(copyWeightObjSkin) elif copyWeightObjSkin == "": pass skin = mel.eval("findRelatedSkinCluster" +"(\""+ WeightObj+"\")") skin_jntList = cmds.skinCluster(skin,q = True,inf = skin) cmds.skinCluster(skin_jntList,copyWeightObj,mi = 10,rui = False,tsb = True) cmds.copySkinWeights(WeightObj,copyWeightObj,noMirror = True,surfaceAssociation = 'closestPoint',influenceAssociation = 'oneToOne') cmds.select(copyWeightObj) cmds.setAttr(copyWeightObj + '.visibility',0) print copyWeightObj + '------------is ok' else: print WeightObj + '----------- no skinCluster' return WeightObj,None else: print WeightObj + '-----------no object' return None,copyWeightObj
def skinAs(src,dst,smooth=False): ''' ''' # Check inputs if not mc.objExists(src): raise Exception('Source object "'+src+'" does not exist!') if not mc.objExists(dst): raise Exception('Destination object "'+dst+'" does not exist!') # Get source skinCluster srcSkin = findRelatedSkinCluster(src) # Check destination skinCluster dstSkin = findRelatedSkinCluster(dst) # Build destination skinCluster if not dstSkin: srcInfList = mc.skinCluster(srcSkin,q=True,inf=True) dstSkin = mc.skinCluster(srcInfList,dst,rui=False,n=dst+'_skinCluster')[0] # Copy skin weights mc.copySkinWeights(ss=str(srcSkin),ds=str(dstSkin),noMirror=True,sm=smooth) # Return result return dstSkin
def skinAs(src,dst,smooth=False): ''' Bind a destination mesh based on the influence list and weights of the skinCluster of a source mesh. @param src: Source mesh that will be used to determine influence list and weights of destination mesh. @type src: str @param dst: Destination mesh to bind based on source mesh skinCluster. @type dst: str @param smooth: Smooth incoming skinCluster weights for destination mesh. @type smooth: bool ''' # Check inputs if not mc.objExists(src): raise Exception('Source object "'+src+'" does not exist!') if not mc.objExists(dst): raise Exception('Destination object "'+dst+'" does not exist!') # Get source skinCluster srcSkin = findRelatedSkinCluster(src) # Check destination skinCluster dstSkin = findRelatedSkinCluster(dst) # Build destination skinCluster if not dstSkin: dstPrefix = dst.split(':')[-1] srcInfList = mc.skinCluster(srcSkin,q=True,inf=True) dstSkin = mc.skinCluster(srcInfList,dst,toSelectedBones=True,rui=False,n=dstPrefix+'_skinCluster')[0] # Copy skin weights mc.copySkinWeights( sourceSkin=str(srcSkin), destinationSkin=str(dstSkin), surfaceAssociation='closestPoint', influenceAssociation='name', noMirror=True, smooth=smooth ) # Return result return dstSkin
def copySkinLayerById(srcMll, destMll, srcLayerId, influenceAssociation, surfaceAssociation, sampleSpace, normalize, uv=None): ''' Actual work is done here. Copies an individual layer from srcMll to destMll ''' layerName = getLayerName(srcMll, srcLayerId) mc.progressWindow(title='Copy layer: %s' % layerName, progress=0, min=0, max=6, status='Get layer mask') srcMeshName, srcSkn = srcMll.getTargetInfo() destMeshName, destSkn = destMll.getTargetInfo() # parse args kwargs = {'ss': srcSkn, 'ds': destSkn, 'ia': influenceAssociation, 'sa': surfaceAssociation, 'spa': sampleSpace, 'nr': normalize, 'nm': True} if uv: kwargs['uv'] = uv # check that selected objects are valid if False in (srcMll.getLayersAvailable(), destMll.getLayersAvailable()): mc.error("Skinning layers must be initialized on both source and destination meshes") # solo layer on srcMesh disableLayers = soloLayer(srcMll, srcLayerId) # save mask weights origMaskWeights = srcMll.getLayerMask(srcLayerId) # temporarily flood mask to 1, so that we can transfer all the data inside this layer srcMll.setLayerMask(srcLayerId, []) #=========================================================================== # Transfer influence weights #=========================================================================== mc.progressWindow(e=True, status='Get influence weights', step=1) # use maya's copySkinWeights command to transfer weights mc.copySkinWeights(**kwargs) # query and catch weights mc.progressWindow(e=True, status='Transfer influence weights', step=1) destInfluenceWeights = queryWeights(destSkn, destMeshName) #=========================================================================== # Transfer mask weights # This is very messed up, but it's the simplest workaround I can think of... # Basically, we create a new joint "tempSkinLayerMaskTransferer_jnt" bound to both skins # This ensures that we can transfer the mask weights by joint name, # even if influence weights are transfered by other methods #=========================================================================== mc.select(cl=True) mc.progressWindow(e=True, status='Transfer layer mask', step=1) if origMaskWeights: # create tempJnt tempJnt = mc.joint(n='layerMaskTransfer_tempJnt') mc.skinCluster(srcSkn, edit=True, addInfluence=tempJnt) # also create an additional tempJnt to hold the "reversed" weights tempHoldJnt = mc.joint(n='layerMaskTransferHold_tempJnt') mc.skinCluster(srcSkn, edit=True, addInfluence=tempHoldJnt, weight=1, lockWeights=True) mc.skinCluster(srcSkn, inf=tempHoldJnt, e=True, lockWeights=False); # apply mask weights to tempJnt setInfluenceWeight(srcSkn, srcMeshName, tempJnt, origMaskWeights) # use maya's copySkinWeights command, with name as influence association mc.skinCluster(destSkn, edit=True, addInfluence=tempJnt) mc.skinCluster(destSkn, edit=True, addInfluence=tempHoldJnt) kwargs['ia'] = 'name' mc.copySkinWeights(**kwargs) # query and catch weights destMaskWeights = queryWeights(destSkn, destMeshName)[-2] # remove tempJnt mc.skinCluster(srcSkn, edit=True, removeInfluence=tempJnt) mc.skinCluster(srcSkn, edit=True, removeInfluence=tempHoldJnt) mc.skinCluster(destSkn, edit=True, removeInfluence=tempJnt) mc.skinCluster(destSkn, edit=True, removeInfluence=tempHoldJnt) mc.delete(tempJnt) # automatically deletes the holdJnt as well since it is a child else: # if origMaskWeights was uninitialized, just use [] destMaskWeights = [] #=========================================================================== # Reset original skin layer #=========================================================================== # reset mask to original weights srcMll.setLayerMask(srcLayerId, origMaskWeights) # un-solo layer for layerId in disableLayers: srcMll.setLayerEnabled(layerId, True) #=========================================================================== # Add layer to destination skin #=========================================================================== # print destInfluenceWeights mc.progressWindow(e=True, status='Set influence weights', step=1) destLayerId = destMll.createLayer(layerName, forceEmpty=True) influenceCount = len(mc.skinCluster(destSkn, q=True, inf=True)) layerInfluences = list(destMll.listLayerInfluences(destLayerId, False)) if len(layerInfluences) != influenceCount: mc.error('SkinCluster %s has %d influences. But SkinLayer has %s influences.\ Try rebinding this mesh.' % (destSkn, influenceCount, len(layerInfluences))) # set influence weights for influenceId in range(influenceCount): weights = destInfluenceWeights[influenceId] layerInfluenceId = layerInfluences[influenceId][1] # check if the influence has non-zero values, to reduce number of calls if not all(val==0 for val in weights): destMll.setInfluenceWeights(destLayerId, layerInfluenceId, weights) # set mask weights mc.progressWindow(e=True, status='Set layer mask', step=1) destMll.setLayerMask(destLayerId, destMaskWeights) mc.progressWindow(endProgress=True) print 'Sucessfully copied layer %s' % layerName
# skinMesh _skinMesh = 'SkinBody' # mesh cmds.select('Mesh_High',hi=True) _meshShape = cmds.ls(sl=True, type='mesh') cmds.select(_meshShape) _mesh= cmds.pickWalk(d='up') # bindSkin cmds.select(_joint,_mesh) # copy for _item in _mesh: cmds.select(_skinMesh,_item) cmds.copySkinWeights(noMirror=True, surfaceAssociation='closestPoint', influenceAssociation=['closestJoint','closestBone','oneToOne'], normalize=True) # HIK Remove Finger from maya import mel _fingerJnt = [ ( 50,'LeftHandThumb1'), ( 51,'LeftHandThumb2'), # 51 ( 52,'LeftHandThumb3'), # 52 ( 53,'LeftHandThumb4'), # 53 ( 54,'LeftHandIndex1'), # 54 ( 55,'LeftHandIndex2'), # 55 ---- ( 56,'LeftHandIndex3'), # 56 ( 57,'LeftHandIndex4'), # 57 ( 58,'LeftHandMiddle1'), # 58 ( 59,'LeftHandMiddle2'), # 59 ( 60,'LeftHandMiddle3'), # 60 ----
import maya.cmds as cmds obj01 = 'model_low' selList = cmds.ls(sl = True) len(selList) print len(selList) for sel in selList: cmds.copySkinWeights(obj01,sel,noMirror = True,surfaceAssociation = 'closestPoint',influenceAssociation = 'oneToOne') ################################################# import maya.cmds as cmds oldObjList = cmds.ls(sl = True) newObjList = [] for oldObj in oldObjList: newObj = oldObj.replace('_old','') newObjList.append(newObj) cmds.select(newObjList) ################################### newObjList = cmds.ls(sl = True) for newObj in newObjList: oldObj = newObj + '_old' if cmds.objExists(oldObj) == True: if mel.eval("findRelatedSkinCluster" +"(\""+ oldObj +"\")") != "": if mel.eval("findRelatedSkinCluster" +"(\""+ newObj +"\")") == "": skin = mel.eval("findRelatedSkinCluster" +"(\""+ oldObj+"\")") skin_jntList = cmds.skinCluster(skin,q = True,inf = skin) cmds.skinCluster(skin_jntList,newObj,mi = 10,rui = False) cmds.copySkinWeights(oldObj,newObj,noMirror = True,surfaceAssociation = 'closestPoint',influenceAssociation = 'oneToOne') cmds.select(newObj) print newObj + '------------is ok' #if mel.eval("findRelatedSkinCluster" +"(\""+ newObj +"\")") == "": else: oldSkin = mel.eval("findRelatedSkinCluster" +"(\""+ oldObj +"\")")
cmds.delete(target,ch=1) # now go through each target objects and do bind and copy weight progressRatio = 20.0 / len(target) for node in target: try: cmds.skinCluster(rootjoint,node,mi = 4,omi = 0,) except Exception , msg: warningCount += 1 print "Failed to bind object %s. %s " % (node,msg) cmds.select(source) cmds.select(node,add=1) try: cmds.copySkinWeights(sm=1,noMirror=1,sa = "closestPoint" , ia = ("name", "oneToOne")) except Exception , msg: warningCount += 1 print "Failed to copy weight object %s. %s " % (node,msg) progressCount = progressCount + progressRatio cmds.progressWindow(e=1,pr=progressCount) progressCount = 40 cmds.progressWindow(e=1,pr=progressCount) #cmds.select(target) #maya.mel.eval("removeUnusedInfluences();") # remove unused influence to optimise skincluster # prune small weight to optimise skincluster even more
def createInfluenceObject(*args, **keywords): # Create a skin patch to locally deformed the skin as influence object # The patch can be deformed by blendShape or nCloth # usage: select faces on a skinned object # TBD: mirror (boolean), combine (boolean), layer # TBD: need to preserve one skin cluster having no influence object (joint binded only, rigid shape w/o collision) # for the creation of attract to matching mesh constraint if 'influenceType' not in keywords: raise Exception, "missing argument influenceType" influenceType = keywords['influenceType'] s = cmds.ls(sl=True, l=True) if not s: raise Exception, "no selection" faces = cmds.polyListComponentConversion(s, tf=True, internal=True) obj = cmds.listRelatives(cmds.ls(sl=True, o=True, l=True), p=True, f=True) sc = jc.helper.findTypeInHistory(obj, 'skinCluster') dup = cmds.duplicate(obj) def f(x): return dup[0] + re.search('\..*', x).group(0) faces = map(f, faces) cmds.polyChipOff(faces, ch=True, kft=True, dup=True, off=0) dup = cmds.listRelatives(list(set(cmds.ls(faces, o=True, l=True))), p=True, f=True) objs = cmds.polySeparate(dup, ch=False, rs=True) def f(x): return len(cmds.ls(cmds.polyListComponentConversion(x, tf=True), fl=True, l=True)) face_counts = map(f, objs) cmds.delete(objs[face_counts.index(max(face_counts))]) objs.pop(face_counts.index(max(face_counts))) jts = jc.helper.findTypeInHistory(sc, 'joint') for o in objs: if influenceType == "blendShape": dup = cmds.duplicate(o, rr=True) (x1,y1,z1, x2,y2,z2) = cmds.exactWorldBoundingBox(obj) cmds.move((x2-x1), 0, 0, dup, r=True) # bind objs to sc, then copy skin weights from obj to objs sc2 = cmds.skinCluster(jts, o)[0] cmds.copySkinWeights(ss=sc, ds=sc2, nm=True, sa="closestPoint", ia="closestJoint") if influenceType == "blendShape": bs = cmds.blendShape(dup, o, foc=True) cmds.setAttr(bs[0]+"."+dup[0], 1) elif influenceType == "nCloth": cmds.select(o, r=True) mel.eval("createNCloth 0;") ncloth = cmds.ls(sl=True) if ncloth: ncloth = ncloth[0] cmds.setAttr(ncloth+".inputMeshAttract", 2) cmds.select(o, r=True) jc.clothes.__updateNClothAttribute(cmds.ls(cmds.polyListComponentConversion(o, tv=True), fl=True), "inputMeshAttract", 0.03) cmds.select(cmds.polyListComponentConversion(o, te=True), r=True) cmds.polySelectConstraint(m=2, w=1) cmds.select(cmds.polyListComponentConversion(tv=True), r=True) cmds.polySelectConstraint(m=0, w=0) jc.clothes.__updateNClothAttribute(cmds.ls(sl=True, fl=True), "inputMeshAttract", 1) cmds.setAttr(sc+".useComponents", 1) def f((x,y)): return x-y for o in objs: cmds.skinCluster(sc, e=True, ug=True, dr=99, ps=0, ai=o) pts = [] (x1,y1,z1, x2,y2,z2) = cmds.exactWorldBoundingBox(o) for v in cmds.ls(cmds.polyListComponentConversion(obj, tv=True), fl=True, l=True): outside = True (x,y,z) = cmds.pointPosition(v) if x>x1 and x<x2 and y>y1 and y<y2 and z>z1 and z<z2: for u in cmds.ls(cmds.polyListComponentConversion(o, tv=True), fl=True, l=True): zp = zip([x,y,z], cmds.pointPosition(u)) (dx,dy,dz) = map(f, zp) if abs(dx) < 0.0001 and abs(dy) < 0.0001 and abs(dz) < 0.0001: outside = False break if outside: pts.append(v) if pts: cmds.skinPercent(sc, pts, tv=[o, 0]) return
def GenerateMocapMeshAndCopyOrgWeight(self ): orgMesh = mc.ls(sl=1) # create name name='' while name == '': result = mc.promptDialog(title='Charactor Name',message='Enter Name:',button=['OK', 'Cancel'],defaultButton='OK',cancelButton='Cancel',dismissString='Cancel') if result == 'OK': name = mc.promptDialog(query=True, text=True)+'_' # create mocap group. # get mocap skin joints. mocapMeshGrp = mc.createNode('transform' , name=name+'mocap_grp') mocapInfList = self.CopyAndRename(self.mohipJnt , name) mc.parent(mocapInfList[0] , mocapMeshGrp) #get waist skin joints. spineSkinJnt = mc.ls( self.spineSkinGrp , dag=1 , type='joint') waistJnt = [self.hipJnt] for x in spineSkinJnt: if 'waist' in x: waistJnt.append(x) waistJnt.append(self.chestJnt) #----------------progressing win progressWin = mc.window(title = "create mocap rig") mc.columnLayout(adj = True) if len(orgMesh)==1: pointsNum=1 elif len(orgMesh)>1: pointsNum = len(orgMesh)-1 progressControl = mc.progressBar(maxValue = pointsNum, width=300) mc.showWindow( progressWin ) #---------------- progressing win for x in orgMesh: if mc.progressWindow( query=True, isCancelled=True ): break #get old mesh skincluster / old skin joints. oldskinNode = self.searchSkinCluster(x) oldInfulence = mc.skinCluster(oldskinNode,query=True,inf=True) #set new bridge mesh need skin joints / new mesh. newInfulence = oldInfulence newMesh = mc.duplicate(x, name=str(x)+'_mocapmodel')[0] mc.parent(newMesh , mocapMeshGrp) # skin the bridge mesh and copy skin weight from old mesh. mc.skinCluster(newInfulence , newMesh , tsb=True) mc.copySkinWeights(x , newMesh , noMirror=True , surfaceAssociation='closestPoint' , influenceAssociation='oneToOne') #locked all the joints skin weight. for j in newInfulence: mc.setAttr(j+'.liw' , 1) mc.select(cl=1) # edit skin weight about body twsit joints. self.SetSkinWeight( newMesh , self.LUparmHoldJnt , self.LUparmAimJnt) self.SetSkinWeight( newMesh , self.LDnarmHoldJnt , self.LDnarmAimJnt) self.SetSkinWeight( newMesh , self.RUparmHoldJnt , self.RUparmAimJnt) self.SetSkinWeight( newMesh , self.RDnarmHoldJnt , self.RDnarmAimJnt) self.SetSkinWeight( newMesh , self.LUplegHoldJnt , self.LUplegAimJnt) self.SetSkinWeight( newMesh , self.LDnlegHoldJnt , self.LDnlegAimJnt) self.SetSkinWeight( newMesh , self.RUplegHoldJnt , self.RUplegAimJnt) self.SetSkinWeight( newMesh , self.RDnlegHoldJnt , self.RDnlegAimJnt) # get spine holdjnt / aimJnt spineAimJnt = [] spineHoldJnt=[] if len(spineSkinJnt) == len(waistJnt): pass else: #hold for i in range(0 , len(waistJnt) , 2): if i!=len(waistJnt)-1: spineHoldJnt.append(waistJnt[i]) #aim for i in range(1 , len(waistJnt) , 2): spineAimJnt.append(waistJnt[i]) #edit spine skin weight. for i in range( len(spineHoldJnt) ): self.SetSkinWeight( newMesh , spineHoldJnt[i] , aimJnt=[ spineAimJnt[i] ] ) #set final mocap mesh /// #use the mocap skin joints create skincluster mocapMesh = mc.duplicate(newMesh, name=str(x)+'_mocapMesh')[0] mc.skinCluster(mocapInfList , mocapMesh , tsb=True) mc.copySkinWeights(newMesh , mocapMesh , noMirror=True , surfaceAssociation='closestPoint' , influenceAssociation='closestJoint') mc.delete(newMesh) mc.progressBar(progressControl, edit=True, step=1) mc.deleteUI(progressWin)