On Thu, Jul 2, 2009 at 09:33, Omar Agudo<[email protected]> wrote:
>
> I have used the API command for coloring per vertex, but this command
> doesn´t work properly, maybe I am doing somethig wrong, but I don´t
> see what I am doing wrong. Have someone have the same problem??
Let's assume that you have a mesh named 'myMeshShape' and you want to
color vertex 2 to be red. Using commands, you can do the following:
import maya.cmds as mc
# Turn on the mesh's color display.
mc.setAttr('myMeshShape.displayColors', True)
# Set the color of vertex 2 to be red.
mc.select('myMeshShape.vtx[2]', r=1, g=0, b=0)
Note that to see the colours you must set the view to be in shaded
mode rather than wireframe.
To do the same thing using API calls:
import maya.OpenMaya as om
# Get the mesh's dag path.
sel = om.MSelectionList()
sel.add('myMeshShape')
meshPath = om.MDagPath()
sel.getDagPath(0, meshPath)
# Create a function set for the mesh.
meshFn = om.MFnMesh(meshPath)
# Turn on the mesh's color display.
meshFn.findPlug('displayColors').setBool(True)
# Set the color of vertex 2 to be red.
red = om.MColor(1, 0, 0)
meshFn.setVertexColor(red, 2)
If you're using PyMEL then some of the above can be simplified even further.
--
-deane
--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/python_inside_maya
-~----------~----~----~----~------~----~------~--~---