Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import maya.api.OpenMaya as om
- import pymel.core as pm
- # API get the mesh
- selList = om.MGlobal.getActiveSelectionList()
- dagPath = selList.getDagPath(0)
- selMesh = om.MFnMesh(dagPath)
- #Get vert list
- vertList = list(set(selMesh.getVertices()[1]))
- #Get points and values
- pointsList = selMesh.getPoints(om.MSpace.kWorld)
- pointsDirList = sorted([p[1] for p in pointsList])
- pMin = min(pointsDirList)
- pMax = max(pointsDirList)
- normalized = []
- for val in pointsDirList:
- #Get normalized values
- norm = (val-pMin) / (pMax-pMin)
- normalized.append(norm)
- for n, v in enumerate(vertList):
- c = om.MColor([normalized[n], 0.0, 0.0])
- selMesh.setVertexColor(c, vertList[n])
Advertisement
Add Comment
Please, Sign In to add comment