avoorhees

Untitled

May 1st, 2017
961
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.69 KB | None | 0 0
  1. import maya.api.OpenMaya as om
  2. import pymel.core as pm
  3.  
  4. # API get the mesh
  5. selList = om.MGlobal.getActiveSelectionList()
  6. dagPath = selList.getDagPath(0)
  7. selMesh = om.MFnMesh(dagPath)
  8.  
  9. #Get vert list
  10. vertList = list(set(selMesh.getVertices()[1]))
  11.  
  12. #Get points and values
  13. pointsList = selMesh.getPoints(om.MSpace.kWorld)
  14. pointsDirList = sorted([p[1] for p in pointsList])
  15. pMin = min(pointsDirList)
  16. pMax = max(pointsDirList)
  17.  
  18. normalized = []
  19. for val in pointsDirList:
  20.     #Get normalized values
  21.     norm = (val-pMin) / (pMax-pMin)
  22.     normalized.append(norm)
  23.  
  24. for n, v in enumerate(vertList):
  25.     c = om.MColor([normalized[n], 0.0, 0.0])
  26.     selMesh.setVertexColor(c, vertList[n])
Advertisement
Add Comment
Please, Sign In to add comment