Exemplo n.º 1
0
 def chk004(self):  #Ignore backfacing (camera based selection)
     if self.ui.chk004.isChecked():
         pm.selectPref(useDepth=True)
         func.viewPortMessage("Camera-based selection <hl>On</hl>.")
     else:
         pm.selectPref(useDepth=False)
         func.viewPortMessage("Camera-based selection <hl>Off</hl>.")
Exemplo n.º 2
0
 def b012(self):  #Find and select N-gons
     #Change to Component mode to retain object highlighting for better visibility
     pm.changeSelectMode(component=1)
     #Change to Face Component Mode
     pm.selectType(smp=0, sme=1, smf=0, smu=0, pv=0, pe=1, pf=0, puv=0)
     #Select Object/s and Run Script to highlight N-Gons
     pm.polySelectConstraint(mode=3, type=0x0008, size=3)
     pm.polySelectConstraint(disable=1)
     #Populate an in-view message
     nGons = pm.polyEvaluate(faceComponent=1)
     func.viewPortMessage("<hl>" + str(nGons[0]) + "</hl> N-Gon(s) found.")
Exemplo n.º 3
0
    def b016(self):  #Delete history
        all_ = self.ui.chk018.isChecked()
        unusedNodes = self.ui.chk019.isChecked()
        deformers = self.ui.chk020.isChecked()
        objects = pm.ls(selection=1)
        if all_:
            objects = pm.ls(typ="mesh")

        for obj in objects:
            try:
                if all_:
                    pm.delete(obj, constructionHistory=1)
                else:
                    pm.bakePartialHistory(obj, prePostDeformers=1)
            except:
                pass
        if unusedNodes:
            maxEval(
                'hyperShadePanelMenuCommand("hyperShadePanel1", "deleteUnusedNodes");'
            )

        #display viewPort messages
        if all_:
            if deformers:
                func.viewPortMessage("delete <hl>all</hl> history.")
            else:
                func.viewPortMessage(
                    "delete <hl>all non-deformer</hl> history.")
        else:
            if deformers:
                func.viewPortMessage("delete history on " + str(objects))
            else:
                func.viewPortMessage(
                    "delete <hl>non-deformer</hl> history on " + str(objects))
Exemplo n.º 4
0
    def b011(self):  #toggle component ID display
        index = func.cycle('componentID_01234')

        visible = pm.polyOptions(query=1, displayItemNumbers=1)
        dinArray = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]

        if index == 4:
            i = 0
            for _ in range(4):
                if visible[i] == True:
                    pm.polyOptions(relative=1,
                                   displayItemNumbers=dinArray[i],
                                   activeObjects=1)
                i += 1

        if visible[index] != True and index != 4:
            pm.polyOptions(relative=1,
                           displayItemNumbers=dinArray[index],
                           activeObjects=1)

            i = 0
            for _ in range(4):
                if visible[i] == True and i != index:
                    pm.polyOptions(relative=1,
                                   displayItemNumbers=dinArray[i],
                                   activeObjects=1)
                i += 1

        if index == 0:
            func.viewPortMessage("[1,0,0,0] <hl>vertIDs</hl>.")
        if index == 1:
            func.viewPortMessage("[0,1,0,0] <hl>edgeIDs</hl>.")
        if index == 2:
            func.viewPortMessage("[0,0,1,0] <hl>faceIDs</hl>.")
        if index == 3:
            func.viewPortMessage("[0,0,0,1] <hl>compIDs(UV)</hl>.")
        if index == 4:
            func.viewPortMessage("component ID <hl>Off</hl>.")
Exemplo n.º 5
0
    def b032(
        self
    ):  #Delete component or if object selected, along axis   #maxEval('polyMirrorCut 1 1 0.001;')
        selectionMask = pm.selectMode(query=True, component=True)
        maskVertex = pm.selectType(query=True, vertex=True)
        maskEdge = pm.selectType(query=True, edge=True)
        # maskFacet = pm.selectType (query=True, facet=True)

        if all([selectionMask == 1, maskEdge == 1]):  #delete edges
            pm.polyDelEdge(cleanVertices=True)
            func.viewPortMessage("delete <hl>edge(s)</hl>.")

        if all([selectionMask == 1, maskVertex == 1]):  #delete vertices
            pm.polyDelVertex()
            func.viewPortMessage("delete <hl>vertice(s)</hl>.")

        if selectionMask == 0:  #object mode /delete faces along axis
            if self.ui.chk002.isChecked():
                axis = "x"
                if self.ui.chk001.isChecked():
                    axis = "-x"
            if self.ui.chk003.isChecked():
                axis = "y"
                if self.ui.chk001.isChecked():
                    axis = "-y"
            if self.ui.chk004.isChecked():
                axis = "z"
                if self.ui.chk001.isChecked():
                    axis = "-z"

            faces = func.getAllFacesOnAxis(axis)
            pm.delete(faces)
            func.viewPortMessage("delete faces on <hl>" + axis + "</hl>.")
            return axis

        else:
            pm.delete()
            func.viewPortMessage("delete.")
    def b000(self):  #save
        preSaveScript = ""
        postSaveScript = ""

        type_ = "mayaBinary"
        if self.ui.chk003.isChecked():  #toggle ascii/ binary
            type_ = "mayaAscii"  #type: mayaAscii, mayaBinary, mel, OBJ, directory, plug-in, audio, move, EPS, Adobe(R) Illustrator(R)

        if self.ui.chk000.isChecked():
            mel.eval("DisplayWireframe;")

        #get scene name and file path
        fullPath = str(
            mel.eval("file -query -sceneName;")
        )  #ie. O:/Cloud/____Graphics/______project_files/elise.proj/elise.scenes/.maya/elise_mid.009.mb
        index = fullPath.rfind("/") + 1
        curFullName = fullPath[index:]  #ie. elise_mid.009.mb
        currentPath = fullPath[:
                               index]  #ie. O:/Cloud/____Graphics/______project_files/elise.proj/elise.scenes/.maya/

        if self.ui.chk001.isChecked():  #increment filename
            import re, os, fnmatch, shutil
            incrementAmount = 5

            #remove filetype extention
            currentName = curFullName[:curFullName.rfind(
                "."
            )]  #name without extension ie. elise_mid.009 from elise_mid.009.mb
            #rename
            numExt = re.search(
                r'\d+$', currentName)  #check if the last chars are numberic
            if numExt is not None:
                name = currentName[:currentName.rfind(
                    '.'
                )]  #strip off the number ie. elise_mid from elise_mid.009
                num = int(numExt.group()
                          ) + 1  #get file number and add 1 ie. 9 becomes 10
                prefix = '000'[:-len(str(num))] + str(
                    num
                )  #prefix '000' removing zeros according to num length ie. 009 becomes 010
                newName = name + '.' + prefix  #ie. elise_mid.010

                #delete older files if they exist:
                oldNum = num - incrementAmount
                oldPrefix = '000'[:-len(str(oldNum))] + str(
                    oldNum
                )  #prefix the appropriate amount of zeros in front of the old number
                oldName = name + '.' + oldPrefix  #ie. elise_mid.007
                try:  #search recursively through the project folder and delete any old folders with the old filename
                    dir_ = os.path.abspath(os.path.join(currentPath, "../.."))
                    for root, directories, files in os.walk(dir_):
                        for filename in files:
                            if all([
                                    filename == oldName + ext
                                    for ext in ('.ma', '.ma.swatches', '.mb',
                                                '.mb.swatches')
                            ]):
                                func.try_('os.remove(filename)')
                except OSError:
                    print "# Warning: could not delete " + currentPath + oldName + " #"
                    pass
            else:
                newName = currentName + ".001"
            pm.saveAs(currentPath + newName,
                      force=1,
                      preSaveScript=preSaveScript,
                      postSaveScript=postSaveScript,
                      type=type_)
            print "// Result: ", currentPath + newName
        else:  #save without renaming
            pm.saveFile(force=1,
                        preSaveScript=preSaveScript,
                        postSaveScript=postSaveScript,
                        type=type_)
            print "// Result: ", currentPath + currentName

        if self.ui.chk002.isChecked():  #quit maya
            import time
            for timer in range(5):
                func.viewPortMessage("shutting down:<hl>" + str(timer) +
                                     "</hl>")
                time.sleep(timer)
            mel.eval("quit;")
	def v012(self): #component mode:uv
		pm.selectMode (component=True)
		pm.selectType (subdivMeshUV=True, polymeshUV=True)
		func.viewPortMessage("<hl>UV</hl> mask.")
	def v011(self): #object mode
		pm.selectMode (object=True)
		func.viewPortMessage("<hl>object</hl> mode.")
	def v010(self): #component mode:facet
		pm.selectMode (component=True)
		pm.selectType (subdivMeshFace=1, polymeshFace=True)
		func.viewPortMessage("<hl>facet</hl> mask.")
	def v009(self): #component mode:edge
		pm.selectMode (component=True)
		pm.selectType (subdivMeshEdge=1, polymeshEdge=True)
		func.viewPortMessage("<hl>edge</hl> mask.")
	def v008(self): #component mode:vertex
		pm.selectMode (component=True)
		pm.selectType (subdivMeshPoint=1, polymeshVertex=True)
		func.viewPortMessage("<hl>vertex</hl> mask.")