In this example, we'll be looking at how to get information about polygonal geometry, which will form the basis for more complex scripts.
Create a new script, name it polyStats.py
, and add the following code:
import maya.cmds as cmds # examine data for a currently-selected polygonal object def getPolyData(): selectedObjects = cmds.ls(selection=True) obj = selectedObjects[-1] vertNum = cmds.polyEvaluate(obj, vertex=True) print('Vertex Number: ',vertNum) edgeNum = cmds.polyEvaluate(obj, edge=True) print('Edge Number: ', edgeNum) faceNum = cmds.polyEvaluate(obj, face=True) print('Face Number: ',faceNum) getPolyData()
Running the preceding code will result in information about the currently selected polygonal object being printed.