Exemplo n.º 1
0
def grmrebuild(grmsels,trmesh):
    if grmsels!=[]:
        for grmsel in grmsels:
            adj = pm.objExists(grmsel+"Shape_strand_set")
            if adj:
                pm.delete(grmsel+"Shape_strand_set")
            pm.pgYetiCommand(pm.listRelatives(grmsel,c=1),convertToCurves=1)
            grmset = cmds.ls(grmsel+"Shape_strand_set")
            grmcvs = cmds.listConnections(grmset[0],d=1)
            delcvgrps = pm.group(grmcvs)
            newset = cmds.sets(grmcvs,n=grmsel+"_set")
            newgrm = pm.createNode("pgYetiGroom")
            pm.rename(newgrm.getParent(),trmesh.getParent().replace(":","_")+"_grm")
            pm.rename(newgrm,trmesh.getParent().replace(":","_")+"_grmShape")
            pm.connectAttr(trmesh+".worldMesh[0]",newgrm+".inputGeometry",f=1)
            yetitarattrs = grmsel.getShape().listConnections(s=0,type="pgYetiMaya",plugs=1)
            for yetitarattr  in yetitarattrs:
                pm.connectAttr(newgrm+ ".outputData" ,yetitarattr,f=1)
            pm.connectAttr("time1.outTime",newgrm+".currentTime",f=1)
            pm.pgYetiCommand(newgrm,convertFromCurves=newset,inputGeometry=trmesh,stepSize=0.001)
            yetinodesrs = trmesh.listConnections(s=0,type="pgYetiMaya")
            for yetinodesr in yetinodesrs:
                yetiimps = pm.pgYetiGraph(yetinodesr,listNodes=True,type="import")
                if yetiimps!=[]:
                    for yetiimp in yetiimps:
                        if pm.pgYetiGraph(yetinodesr,node=yetiimp,param="type",getParamValue=1)==1:
                            pm.pgYetiGraph(yetinodesr,node=yetiimp,param="geometry",setParamValueString=newgrm.split(":")[-1])
            pm.delete(delcvgrps)
            return newgrm
Exemplo n.º 2
0
def yeticonnectAttr(typename, yetishapesr, yetishapetr):
    yetinodes = []
    if yetishapesr != [] and yetishapetr != []:
        yeticonnects = yetishapesr.listConnections(c=1, type=typename, plugs=1)
        if yeticonnects != []:
            for yeticonnect in yeticonnects:
                yeticonnectsr = yeticonnect[0]
                yeticonnecttr = yeticonnect[1]
                yetinode = yeticonnect[1].split(".")[0]
                pm.connectAttr(yeticonnectsr.replace(str(yetishapesr),
                                                     str(yetishapetr)),
                               yeticonnecttr,
                               f=1)
                if pm.nodeType(yetinode) == "pgYetiMaya":
                    yetiimps = pm.pgYetiGraph(yetinode,
                                              listNodes=True,
                                              type="import")
                    if yetiimps != []:
                        for yetiimp in yetiimps:
                            if pm.pgYetiGraph(yetinode,
                                              node=yetiimp,
                                              param="type",
                                              getParamValue=1) == 0:
                                pm.pgYetiGraph(
                                    yetinode,
                                    node=yetiimp,
                                    param="geometry",
                                    setParamValueString=yetishapetr.split(
                                        "|")[-1].split(":")[-1])
                yetinodes.append(yetinode)
    return yetinodes
Exemplo n.º 3
0
def checktexpath(arg):
    newpath = cmds.textField('tartexpath', tx=1, q=1).replace("\\", "/")
    settexvalue = pm.checkBox("settexpathcb", q=True, v=True)
    copytexvalue = pm.checkBox("copytexpathcb", q=True, v=True)
    wholevalue = pm.checkBox("wholecb", q=True, v=True)
    filewholes = pm.ls(type="file") + [
        u for u in pm.ls(type="pgYetiMaya")
        if pm.pgYetiGraph(u, listNodes=True, type="texture") != []
    ]
    global existspath
    global noexistpath
    existspath = {}
    noexistpath = {}
    for filewhole in filewholes:
        ##非多贴图
        if sjtextool().getpath(filewhole)[0] != {}:
            texnode = sjtextool().getpath(filewhole)[0]
            for texpath in texnode.values():
                if type(texpath) != type({}):
                    filename = os.path.basename(texpath)
                    dirname = os.path.dirname(texpath)
                    ##一般贴图
                    if texnode.keys()[0].getAttr("uvTilingMode") == 0:
                        sjtextool().checkexs(texnode.keys()[0], texpath,
                                             existspath, noexistpath)
                    ##UDIM
                    elif texnode.keys()[0].getAttr("uvTilingMode") == 3:
                        sjtextool().checkexs(texnode.keys()[0], texpath,
                                             existspath, noexistpath)
                    else:
                        print "not supported UVTiling Mode!!",
                else:
                    ##yeti的非udim
                    for y in range(len(texnode.keys())):
                        yetitex = texnode.values()[y]
                        for t in range(len(yetitex.keys())):
                            sjtextool().checkexs(texnode.keys()[y],
                                                 yetitex.values()[t],
                                                 existspath, noexistpath)
        ##多贴图
        if sjtextool().getpath(filewhole)[1] != {}:
            multinode = sjtextool().getpath(filewhole)[1]
            for e in range(len(multinode.values())):
                texattr = multinode.values()[e]
                if pm.nodeType(multinode.keys()[e]) == "file":
                    for x in range(len(texattr.keys())):
                        sjtextool().checkexs(multinode.keys()[e],
                                             texattr.values()[x], existspath,
                                             noexistpath)
                else:
                    ##yeti的udim
                    texattr = multinode.values()[e]
                    for r in range(len(texattr.keys())):
                        sjtextool().checkexs(multinode.keys()[e],
                                             texattr.values()[r], existspath,
                                             noexistpath)
    cmds.textScrollList("nomisslist", e=1, ra=1, a=existspath.keys())
    cmds.textScrollList("misslist", e=1, ra=1, a=noexistpath.keys())
Exemplo n.º 4
0
 def getpath(self, filenode):
     nmfilepath = {}
     mulfilepath = {}
     if pm.nodeType(filenode) == "file":
         if pm.listConnections(filenode, d=0, type="choice") == []:
             nmfilepath[filenode] = pm.getAttr(filenode +
                                               ".fileTextureName").replace(
                                                   "\\", "/")
         else:
             userattr = pm.listAttr(filenode, ud=1)
             userattrpath = {}
             for u in range(len(userattr)):
                 if userattr[u][:3] == "Tex":
                     userattrpath[userattr[u]] = pm.getAttr(
                         filenode + "." + userattr[u]).replace("\\", "/")
             mulfilepath[filenode] = userattrpath
     else:
         try:
             nofiles = filenode.getShape()
         except:
             nofiles = filenode
         if nofiles != []:
             pgyetitexs = pm.pgYetiGraph(pm.PyNode(nofiles),
                                         listNodes=True,
                                         type="texture")
             if pgyetitexs != None:
                 yetipaths = {}
                 yetipathsudim = {}
                 for p in range(len(pgyetitexs)):
                     yetipath = pm.pgYetiGraph(nofiles,
                                               node=pgyetitexs[p],
                                               param="file_name",
                                               getParamValue=True)
                     if yetipath[-10:-4].upper() != "<UDIM>":
                         yetipaths[pgyetitexs[p]] = yetipath
                     else:
                         yetipathsudim[pgyetitexs[p]] = yetipath
                 if yetipaths != {}:
                     nmfilepath[nofiles] = yetipaths
                 if yetipathsudim != {}:
                     mulfilepath[nofiles] = yetipathsudim
     return nmfilepath, mulfilepath
Exemplo n.º 5
0
 def checkTexPath(self):
     if self.yetinum==1:
         filewholes = pm.ls(type="file")+[u for u in pm.ls(type="pgYetiMaya") if pm.pgYetiGraph(u,listNodes=True,type="texture") !=[]]  
     else:
         filewholes = pm.ls(type="file")
     global existspath
     global noexistpath
     existspath = {}
     noexistpath ={}
     for filewhole in filewholes:
         ##非多贴图
         if  texCheckClass().getPath(filewhole)[0] !={}:
             texnode =  texCheckClass().getPath(filewhole)[0]
             for texpath in texnode.values():
                 if type(texpath)!=type({}):
                     filename =  os.path.basename(texpath)
                     dirname = os.path.dirname(texpath)
                     ##一般贴图
                     if texnode.keys()[0].getAttr("uvTilingMode")==0:
                         texCheckClass().checkExs(texnode.keys()[0],texpath,existspath,noexistpath)
                     ##UDIM
                     elif texnode.keys()[0].getAttr("uvTilingMode")==3:
                         texCheckClass().checkExs(texnode.keys()[0],texpath,existspath,noexistpath)
                     else:
                         print "not be supported UVTiling Mode!!",
                 else:
                     if self.yetinum==1:
                         ##yeti的非udim
                         for y in range(len(texnode.keys())):
                             yetitex = texnode.values()[y]
                             for t in range(len(yetitex.keys())):
                                 texCheckClass().checkExs(texnode.keys()[y],yetitex.values()[t],existspath,noexistpath)
                     else:
                         pass
         ##多贴图
         if texCheckClass().getPath(filewhole)[1] !={}:
             multinode =  texCheckClass().getPath(filewhole)[1]
             for e in range(len(multinode.values())):
                 texattr =  multinode.values()[e]
                 if pm.nodeType(multinode.keys()[e])=="file":
                     for x in range(len(texattr.keys())):
                         texCheckClass().checkExs(multinode.keys()[e],texattr.values()[x],existspath,noexistpath)
                 else:
                     if self.yetinum==1:
                         ##yeti的udim
                         texattr =  multinode.values()[e]
                         for r in range(len(texattr.keys())):
                             texCheckClass().checkExs(multinode.keys()[e],texattr.values()[r],existspath,noexistpath)
                     else:
                         pass
     return existspath,noexistpath
Exemplo n.º 6
0
    def setcopy(self, filenode, yetitex, path, tarpaths, filetexname, setv,
                copyv, whole, absolute):
        #(节点名,yeti贴图节点,原始路径,目标路径,属性名,是否设置贴图,是否拷贝贴图,是否启动全局模式)
        if whole == 0:
            tarpath = tarpaths
        else:
            if path.find("sourceimages") != -1:
                tarpath = os.path.dirname(
                    tarpaths) + "/" + path[path.find("sourceimages"):]
            else:
                tarpath = tarpaths
        if pm.nodeType(filenode) == "file":
            if path != tarpath:
                fileudimadj = os.path.splitext(os.path.basename(path))[0][-6:]
                orginalmode = filenode.getAttr("uvTilingMode")
                if fileudimadj.upper() != "<UDIM>":
                    if orginalmode == 0:
                        if os.path.exists(os.path.dirname(path)):
                            if copyv == 1:
                                if os.path.exists(tarpath):
                                    os.remove(tarpath)
                                if os.path.exists(
                                        os.path.dirname(tarpath)) != True:
                                    os.makedirs(os.path.dirname(tarpath),
                                                mode=0777)
                                if os.path.exists(
                                        os.path.dirname(tarpath)) != True:
                                    os.makedirs(os.path.dirname(tarpath),
                                                mode=0777)
                                pm.sysFile(path, copy=tarpath)
                        else:
                            if setv == 1:
                                if absolute == 0:
                                    pm.setAttr(filenode + "." + filetexname,
                                               tarpath,
                                               type="string")
                                else:
                                    if path.find("sourceimages") != -1:
                                        pm.setAttr(
                                            filenode + "." + filetexname,
                                            path[path.find("sourceimages"):],
                                            type="string")
                                    else:
                                        "no sourceimages!!",
                    else:
                        if os.path.exists(os.path.dirname(path)) == True:
                            filelists = os.listdir(os.path.dirname(path))
                            for filelist in filelists:
                                if os.path.splitext(
                                        filelist)[0][:-4] == os.path.splitext(
                                            os.path.basename(path))[0][:-4]:
                                    if os.path.exists(
                                            os.path.dirname(tarpath) + "/" +
                                            filelist):
                                        os.remove(
                                            os.path.dirname(tarpath) + "/" +
                                            filelist)
                                        if os.path.exists(
                                                os.path.dirname(
                                                    tarpath)) != True:
                                            os.makedirs(
                                                os.path.dirname(tarpath),
                                                mode=0777)
                                        pm.sysFile(
                                            os.path.dirname(path) + "/" +
                                            filelist,
                                            copy=os.path.dirname(tarpath) +
                                            "/" + filelist)
                                    else:
                                        if os.path.exists(
                                                os.path.dirname(
                                                    tarpath)) != True:
                                            os.makedirs(
                                                os.path.dirname(tarpath),
                                                mode=0777)
                                        pm.sysFile(
                                            os.path.dirname(path) + "/" +
                                            filelist,
                                            copy=os.path.dirname(tarpath) +
                                            "/" + filelist)
                                else:
                                    if setv == 1:
                                        filenode.setAttr("uvTilingMode", 0)
                                        if absolute == 0:
                                            pm.setAttr(filenode + "." +
                                                       filetexname,
                                                       tarpath,
                                                       type="string")
                                        else:
                                            if path.find("sourceimages") != -1:
                                                pm.setAttr(
                                                    filenode + "." +
                                                    filetexname,
                                                    path[path.find(
                                                        "sourceimages"):],
                                                    type="string")
                                            else:
                                                "no sourceimages!!",
                                        filenode.setAttr(
                                            "uvTilingMode", int(orginalmode))
                        else:
                            if setv == 1:
                                filenode.setAttr("uvTilingMode", 0)
                                if absolute == 0:
                                    pm.setAttr(filenode + "." + filetexname,
                                               tarpath,
                                               type="string")
                                else:
                                    if path.find("sourceimages") != -1:
                                        pm.setAttr(
                                            filenode + "." + filetexname,
                                            path[path.find("sourceimages"):],
                                            type="string")
                                    else:
                                        "no sourceimages!!",
                                filenode.setAttr("uvTilingMode",
                                                 int(orginalmode))
                    if setv == 1:
                        if orginalmode == 0:
                            if absolute == 0:
                                pm.setAttr(filenode + "." + filetexname,
                                           tarpath,
                                           type="string")
                            else:
                                if path.find("sourceimages") != -1:
                                    pm.setAttr(
                                        filenode + "." + filetexname,
                                        path[path.find("sourceimages"):],
                                        type="string")
                                else:
                                    "no sourceimages!!",
                        else:
                            filenode.setAttr("uvTilingMode", 0)
                            if absolute == 0:
                                pm.setAttr(filenode + "." + filetexname,
                                           tarpath,
                                           type="string")
                            else:
                                if path.find("sourceimages") != -1:
                                    pm.setAttr(
                                        filenode + "." + filetexname,
                                        path[path.find("sourceimages"):],
                                        type="string")
                                else:
                                    "no sourceimages!!",
                            filenode.setAttr("uvTilingMode", int(orginalmode))
                else:
                    if os.path.exists(os.path.dirname(path)):
                        filelists = os.listdir(os.path.dirname(path))
                    elif os.path.exists(os.path.dirname(tarpaths)):
                        filelists = os.listdir(os.path.dirname(tarpaths))
                    else:
                        filelists = []
                    if filelists != []:
                        for filelist in filelists:
                            print filelist
                            if os.path.splitext(
                                    filelist)[0][:-4] == os.path.splitext(
                                        os.path.basename(path))[0][:-6]:
                                if copyv == 1:
                                    if os.path.exists(
                                            os.path.dirname(tarpath) + "/" +
                                            filelist):
                                        os.remove(
                                            os.path.dirname(tarpath) + "/" +
                                            filelist)
                                    else:
                                        pass
                                    if os.path.exists(
                                            os.path.dirname(tarpath)) != True:
                                        os.makedirs(os.path.dirname(tarpath),
                                                    mode=0777)
                                    else:
                                        pass
                                    pm.sysFile(
                                        os.path.dirname(path) + "/" + filelist,
                                        copy=os.path.dirname(tarpath) + "/" +
                                        filelist)
                                else:
                                    pass
                            else:
                                if setv == 1:
                                    filenode.setAttr("uvTilingMode", 0)
                                    if absolute == 0:
                                        pm.setAttr(filenode + "." +
                                                   filetexname,
                                                   tarpath,
                                                   type="string")
                                    else:
                                        if path.find("sourceimages") != -1:
                                            pm.setAttr(
                                                filenode + "." + filetexname,
                                                path[path.find("sourceimages"
                                                               ):],
                                                type="string")
                                        else:
                                            "no sourceimages!!",
                                    filenode.setAttr("uvTilingMode",
                                                     int(orginalmode))
                        if setv == 1:
                            if orginalmode == 0:
                                if absolute == 0:
                                    pm.setAttr(filenode + "." + filetexname,
                                               tarpath,
                                               type="string")
                                else:
                                    if path.find("sourceimages") != -1:
                                        pm.setAttr(
                                            filenode + "." + filetexname,
                                            path[path.find("sourceimages"):],
                                            type="string")
                                    else:
                                        "no sourceimages!!",
                            else:
                                filenode.setAttr("uvTilingMode", 0)
                                if absolute == 0:
                                    pm.setAttr(filenode + "." + filetexname,
                                               tarpath,
                                               type="string")
                                else:
                                    if path.find("sourceimages") != -1:
                                        pm.setAttr(
                                            filenode + "." + filetexname,
                                            path[path.find("sourceimages"):],
                                            type="string")
                                    else:
                                        "no sourceimages!!",
                                filenode.setAttr("uvTilingMode",
                                                 int(orginalmode))
        elif pm.nodeType(filenode) == "pgYetiMaya":
            if path != tarpath:
                yetiudimadj = os.path.splitext(os.path.basename(path))[0][-6:]
                if yetiudimadj.upper() != "<UDIM>":
                    if os.path.exists(os.path.dirname(path)):
                        if copyv == 1:
                            if os.path.exists(tarpath):
                                os.remove(tarpath)
                            else:
                                pass
                            if os.path.exists(
                                    os.path.dirname(tarpath)) != True:
                                os.mkdir(os.path.dirname(tarpath))
                            else:
                                pass
                            pm.sysFile(path, copy=tarpath)
                        if setv == 1:
                            pm.pgYetiGraph(filenode,
                                           node=yetitex,
                                           param="file_name",
                                           setParamValueString=str(tarpath))
                    else:
                        if setv == 1:
                            pm.pgYetiGraph(filenode,
                                           node=yetitex,
                                           param="file_name",
                                           setParamValueString=str(tarpath))
                else:
                    if os.path.exists(path) == True:
                        filelists = os.listdir(os.path.dirname(path))
                    else:
                        filelists = os.listdir(os.path.dirname(tarpath))

                    for filelist in filelists:
                        if os.path.splitext(
                                filelist)[0][:-4] == os.path.splitext(
                                    os.path.basename(path))[0][:-6]:
                            if copyv == 1:
                                if os.path.exists(
                                        os.path.dirname(tarpath) + "/" +
                                        filelist):
                                    os.remove(
                                        os.path.dirname(tarpath) + "/" +
                                        filelist)
                                else:
                                    pass
                                if os.path.exists(
                                        os.path.dirname(tarpath)) != True:
                                    os.makedirs(os.path.dirname(tarpath),
                                                mode=0777)
                                else:
                                    pass
                                pm.sysFile(
                                    os.path.dirname(path) + "/" + filelist,
                                    copy=os.path.dirname(tarpath) + "/" +
                                    filelist)
                            else:
                                pass
                        else:
                            if setv == 1:
                                pm.pgYetiGraph(
                                    filenode,
                                    node=yetitex,
                                    param="file_name",
                                    setParamValueString=str(tarpath))

                    if setv == 1:
                        pm.pgYetiGraph(filenode,
                                       node=yetitex,
                                       param="file_name",
                                       setParamValueString=str(tarpath))
                    else:
                        pass
            else:
                pass
        return tarpath