Skip to content

Instantly share code, notes, and snippets.

@hotcakesdeluxe
Created November 19, 2018 22:11
Show Gist options
  • Save hotcakesdeluxe/54438b12e6ebad1ce9fd882f5862d184 to your computer and use it in GitHub Desktop.
Save hotcakesdeluxe/54438b12e6ebad1ce9fd882f5862d184 to your computer and use it in GitHub Desktop.
import maya.cmds as mc
import maya.OpenMaya as OpenMaya
def getVertices(mesh):
mc.select(mesh)
selList = OpenMaya.MSelectionList()
OpenMaya.MGlobal.getActiveSelectionList(selList)
meshObj = OpenMaya.MObject()
selList.getDependNode(0,meshObj)
meshFn = OpenMaya.MFnMesh( meshObj )
meshVtxCount = OpenMaya.MIntArray()
meshVtxArray = OpenMaya.MIntArray()
meshFn.getVertices(meshVtxCount,meshVtxArray)
vtxList = []
for i in range(meshVtxArray.length()):
vtxList.append(meshVtxArray[i])
print len(vtxList)
return vtxList
getVertices("pCubeShape1")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment