Python maya.cmds.polyEvaluate() Examples

The following are 9 code examples of maya.cmds.polyEvaluate(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module maya.cmds , or try the search function .
Example #1
Source File: uv.py    From SISideBar with MIT License 6 votes vote down vote up
def checkCurrentUV(self):
        if self.force:
            return True
        if cmds.polyEvaluate(self.mesh, uv=True, uvs=self.currentSet[0]) == 0:
            msg04 = lang.Lang(
                en=str(self.mesh)+' : Current UVSet ['+str(self.currentSet[0])+'] is empty.\nDo you skip this mesh?',
                ja=self.mesh+u' : 現在のUVSet ['+self.currentSet[0]+u'] が空です。\nこのメッシュをスキップしますか?'
            )   
            self.msg04 = msg04.output()
            self.skipMesh = cmds.confirmDialog(m=self.msg04, t='', b= [self.msg02, self.msg03], db=self.msg02, cb=self.msg03, icn='question',ds=self.msg03)
        else:
            return True#スキップしない
        if self.skipMesh == self.msg02:
            return False#スキップする
        else:
            return True#スキップしない 
Example #2
Source File: benchmark.py    From tutorials with MIT License 6 votes vote down vote up
def testPyCmds():

    start = time.time()

    helix = cmds.polyHelix(**HELIX_OPTS)
    pHelix = helix[0]

    size = cmds.polyEvaluate(v=True)

    for i in xrange(size):
        x = RAND.uniform(LOW, HIGH)
        attrib = '%s.vtx[%s]' % (pHelix, i)
        cmds.move(x, attrib, x=True)
    
    cmds.delete(pHelix)

    end = time.time()
    return end-start 
Example #3
Source File: AEsporeNodeTemplate.py    From spore with MIT License 5 votes vote down vote up
def estimate_num_samples(self, node):
        """ estimate how many random samples we need for grid or disk sampling """

        self._node = node
        emit_type = cmds.getAttr('{}.emitType'.format(node))
        if emit_type == 1:
            cell_size = cmds.getAttr(self._node + '.cellSize')
        elif emit_type == 2:
            cell_size = cmds.getAttr(self._node + '.minRadius') / math.sqrt(3)
        else:
            return

        in_mesh = node_utils.get_connected_in_mesh(self._node)
        area = cmds.polyEvaluate(in_mesh, worldArea=True)
        cmds.setAttr(self._node + '.numSamples', int(area/cell_size) * 5) 
Example #4
Source File: freeze.py    From SISideBar with MIT License 5 votes vote down vote up
def deleteZeroShape(node):
    meshnode = cmds.listRelatives(node, s=True, pa=True, type='mesh', fullPath=True)
    for mesh in meshnode:
        triNum = cmds.polyEvaluate(mesh, triangle=True)
        historyNode = cmds.listHistory(mesh, f=True)
        if len(historyNode) <= 1:
            cmds.delete(mesh) 
Example #5
Source File: dm2skin.py    From dm2skin with The Unlicense 5 votes vote down vote up
def dm2skin_getVertexPositionsOverRange(mesh, startFrame=0, endFrame=1):
    """Gets a list of lists of vertex positions for the given mesh. One list for
    each frame between startFrame and endFrame."""
    numVerts = cmds.polyEvaluate(mesh, v=True)
    resultList = []
    for i in range(startFrame, endFrame + 1):
        tempList = []
        cmds.currentTime(i)
        for j in range(0, numVerts):
            tempPos = cmds.xform(mesh + '.vtx[' + str(j) + ']', q=True, ws=True, t=True)
            tempList.append(np.array([tempPos[0], tempPos[1], tempPos[2]]))
        resultList.append(tempList)
    return resultList 
Example #6
Source File: dm2skin.py    From dm2skin with The Unlicense 5 votes vote down vote up
def dm2skin_getVertexLocationList(mesh, frame=0):
    """Gets a list of vertex locations on the given frame."""
    numVerts = cmds.polyEvaluate(mesh, v=True)
    resultList = []
    cmds.currentTime(frame)
    for v in range(0, numVerts):
        pos = cmds.xform(mesh + '.vtx[' + str(v) + ']', q=True, ws=True, t=True)
        resultList.append(np.array([pos[0], pos[1], pos[2], 1.0]))
    return resultList 
Example #7
Source File: freeze.py    From SIWeightEditor with MIT License 5 votes vote down vote up
def deleteZeroShape(node):
    meshnode = cmds.listRelatives(node, s=True, pa=True, type='mesh', fullPath=True)
    for mesh in meshnode:
        triNum = cmds.polyEvaluate(mesh, triangle=True)
        historyNode = cmds.listHistory(mesh, f=True)
        if len(historyNode) <= 1:
            cmds.delete(mesh) 
Example #8
Source File: uExport.py    From uExport with zlib License 4 votes vote down vote up
def LOD_transferWeights(meshes, jointsToRemove, jointToTransferTo, debug=1, pruneWeights=0.001, *args):
        '''
        Original function by Charles Anderson @ Epic Games
        '''
        for mesh in meshes:

            # Find the skin cluster for the current mesh
            cluster = findCluster(mesh)

            if debug:
                print "MESH: ", mesh
                print "CLUSTER: ", cluster

            # Prune weights on the current mesh
            if pruneWeights:
                cmds.skinPercent(cluster, mesh, prw=pruneWeights)

            # Find all of the current influences on the current skin cluster.
            meshInfluences = cmds.skinCluster(cluster, q=True, inf=True)
            #print "Current Influences: ", meshInfluences

            for joint in jointsToRemove:
                if joint in meshInfluences:
                    #print "Current Joint: ", joint

                    # If the jointToTransferTo is not already an influence on the current mesh then add it.
                    currentInfluences = cmds.skinCluster(cluster, q=True, inf=True)
                    if jointToTransferTo not in currentInfluences:
                        cmds.skinCluster(cluster, e=True, wt=0, ai=jointToTransferTo)

                    # Now transfer all of the influences we want to remove onto the jointToTransferTo.
                    for x in range(cmds.polyEvaluate(mesh, v=True)):
                        #print "TRANSFERRING DATA....."
                        value = cmds.skinPercent(cluster, (mesh+".vtx["+str(x)+"]"), t=joint, q=True)
                        if value > 0:
                            cmds.skinPercent(cluster, (mesh+".vtx["+str(x)+"]"), tmw=[joint, jointToTransferTo])

            # Remove unused influences
            currentInfluences = cmds.skinCluster(cluster, q=True, inf=True)
            #print "Current Influences: ", currentInfluences
            influencesToRemove = []
            weightedInfs = cmds.skinCluster(cluster, q=True, weightedInfluence=True)
            #print "Weighted Influences: ", weightedInfs
            for inf in currentInfluences:
                #print "Influence: ", inf
                if inf not in weightedInfs:
                    #print "Update Influences to Remove List: ", inf
                    influencesToRemove.append(inf)

            #print "ToRemove Influences: ", influencesToRemove
            if influencesToRemove != []:
                for inf in influencesToRemove:
                    cmds.skinCluster(cluster, e=True, ri=inf)

## UI RELATED
########################################################################

    #event filter to grab and discern right/left click 
Example #9
Source File: maya_ExportToExternal.py    From OD_CopyPasteExternal with Apache License 2.0 4 votes vote down vote up
def fn_getObjectData():
    global exportedObj
    curSel = cmds.ls(selection = True)
    if len(curSel) > 0:
        exportedObj.name = curSel[0]
        exportedObj.vertexCount = cmds.polyEvaluate(exportedObj.name, vertex = True)
        exportedObj.polyCount = cmds.polyEvaluate(exportedObj.name, face = True)

        exportedObj.vertices = []
        exportedObj.polys = []
        exportedObj.weightMap = []

        for v in range(0,exportedObj.vertexCount - 0, 1):
            vStr = exportedObj.name + ".vtx[" + str(v) + "]"
            vPos = cmds.xform(vStr, q= True,  os = True, translation = True)
            exportedObj.vertices.append(vPos)
            try:
                w = cmds.polyColorPerVertex(vStr, q = True, r = True)[0]
            except:
                w = -1

            exportedObj.weightMap.append(w)


        for f in range(0,exportedObj.polyCount - 0, 1):
            vStr = exportedObj.name + ".f[" + str(f) + "]"
            cmds.select(vStr, replace = True)
            verts = cmds.polyInfo(fv = True)
            vertsTemp = verts[0].split(":")
            vertsTemp = vertsTemp[1].split(" ")
            vList = []
            for fv in vertsTemp:
                if fv.strip() != "":
                    vList.append(int(fv))
            exportedObj.polys.append(vList)

        cmds.select(curSel, replace = True)
        return True
    else:
        cmds.confirmDialog(title='Error:', message='No object selected!',button='Ok')
        print "Nothing selected!"
        return False