maya權重拷貝一對一,一對多


是不是有時候盔甲很多很碎頭很大,用代理一個個拷貝很麻煩吧

用下面代碼直接運行進行一對多或者一對一拷貝

第一個先選擇參考物體,加選其他一堆有的沒的有權重或沒權重的物體執行一鍵拷貝,就可以啦

以下是源碼送上,帶走吧

 

------------------------

 

 

#! -*- coding:utf -8 -*-

#author:liubingdong

#date:20190427
import  maya.cmds  as  mc
import  maya.mel  as  mel
#一對多拷貝權重
allElement=mc.ls(sl=1)
for  a    in    range(1,len(allElement)):
    canKao=allElement[0]
    currentObj=allElement[a]
    skinnode = mel.eval(' findRelatedSkinCluster  %s'%canKao)
    if  skinnode:
        canKaoGuge=mc.skinCluster(skinnode,q=1,inf=1)
        
        skinnode_new = mel.eval(' findRelatedSkinCluster  %s'%currentObj)
        if skinnode_new:
            zuiZhongGuGe=mc.skinCluster(skinnode_new,q=1,inf=1)
            if zuiZhongGuGe and canKaoGuge:
                if canKaoGuge!=zuiZhongGuGe:
                    #skinCluster -e  -dr 4 -lw true -wt 0 -ai joint1 skinCluster142;
                    newNeedAdd=[]
                    
                    for  eachList  in  canKaoGuge:
                       
                        
                        if eachList not in zuiZhongGuGe:
                            newNeedAdd.append(eachList)
                    if  newNeedAdd!=[]:      
                        for eachNeedAdd  in  newNeedAdd:                            
                            mc.skinCluster( skinnode_new,e=1,  lw=1 , wt= 0,ai= eachNeedAdd )
                    
            
        else:
            #蒙皮
            mc.skinCluster(canKaoGuge, currentObj,rui=0,tsb=True)
            
        #拷貝權重
        mc.select(cl=1)
        mc.select(canKao)
        mc.select(currentObj,add=1)      
        mel.eval('copySkinWeights  -noMirror -surfaceAssociation closestPoint -influenceAssociation oneToOne -influenceAssociation oneToOne -influenceAssociation oneToOne;')
        print ('\n已經拷貝.............',currentObj)
    
        
    -----------------------------

有任何問題聯系我:27971533

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM