[MAYA][PYTHON] polyColorPerVertex very slow

Hello,

Unfortunately the polyColorPerVertex function is getting slower ever in the latest version of Maya… :frowning:

I found a nice sentence here :

https://twitter.com/_andyseymour/status/180946831986008064

Then browsing the doc to the node section :

But no idea how to access to this attribute.
I tried many things but I really to not get it and how how could I force the color to a specific vertex via attribute…

Checking overt the internet and not much content.
Most of every polyColorPerVertex and complaining how it is slow.

Any idea? :?::?:

Thank you :):

Use the Python API to set vertex color on large objects, it is much faster than the MEL command.

oh?
never tried…
Can I mix maya.cmds with maya.api?

Checking the doc right now :

I am a bit late on this, I’ve completely missed it out O_O…

oh found something :

I recently built a tool to apply vertex colors via a soft selection. I also discovered that it’s painfully slow to apply vertex colors piecemeal. Your goal is to make a single Maya API call to mfnMesh.setVertexColors(colors, indices), thus batching all your vertex-color assignments into one super-fast execution.

The setVertexColors method takes in two lists. One list of colors and one list of vertex indices, these map together 1:1. Here is my method that does the work:

 
import maya.api.OpenMaya as api

def apply_api_colors(colors, indices, obj):
     colors = [api.MColor(i) for i in colors]
     selectionList = api.MSelectionList()
     selectionList.add(obj)
     nodeDagPath = selectionList.getDagPath(0)
     mfnMesh = api.MFnMesh(nodeDagPath)
     mfnMesh.setVertexColors(colors, indices)

It works a charm!

A while ago I wrote the very simple skin tool we had on 3dsmax 5.x for Maya 2009 with MelScript

But really got slower from the last version on Maya.
Still working with low poly model then it was just fine even a bit slow…

Then converted my melscript to maya.cmds but still the polyVertexColor thing is just super slow…

Maya.OpenMaya is just marvelous, it works a charm now!! ^___^

Thank you so much for the advise guys!