View Full Version : Get Vertex Color from Mesh

thorsten hartmann
12 December 2010, 11:29 AM
Hi Guy,

i have a newbie question. I have look here at other Treads, but i donīt unterstand. How can i get a the Vertex Color of Vertex[24] from a Mesh?

my_color = my_mesh.getVertexcolor[24] ( donīt work )

hot chip

12 December 2010, 12:03 PM
my_color = getVertColor my_mesh 24

thorsten hartmann
12 December 2010, 04:51 PM
hi AnoPrkl,

thank you for help. I have convert my Poly Object to a Mesh Object, but it comes a error message: "vertex index out of range"

for i=1 to vertex_anzahl do (

vertex_farbe = getVertColor th_mesh i


and what must i do, when my mesh is a editable Poly, because my mesh is a editable Poly Object.

hot chip

12 December 2010, 05:00 PM
You can use,

$.SetVertexColor (color 128 128 128) #VertexColor

This is for an EditablePoly Object, but you have to be in sub-object level 1 I believe with the vertex selected, otherwise it doesn't work.

Hope that helps.

thorsten hartmann
12 December 2010, 05:11 PM
hi matthew

thank you. How can i say Vertex 24 for example, and i must read all Vertex of Poly-Object and check if the Color Red, Green or Blue.

12 December 2010, 05:28 PM
That command works on the selected vertex.

So you would loop through all the verts like...


local theMesh = selection[1]
setCommandPanelTaskMode #modify
subObjectLevel = 1

For v = 1 to theMesh.mesh.verts.count do
theMesh.EditablePoly.SetSelection #Vertex #{v}
local theVertColor = theMesh.getVertexColor #VertexColor
print theVertColor


thorsten hartmann
12 December 2010, 06:51 PM
Super :thumbsup: It workīs. Thank you very much.

hot chip

12 December 2010, 07:24 PM
check MXS Help:
Editable_Poly Mapping Methods
Vertex Colors

the Vertex Color Channel is Map Channel #0

n = converttopoly (box())
polyop.setvertcolor n 0 #{1,4} red
polyop.setvertcolor n 0 #{2,5,7} blue
polyop.setvertcolor n 0 #{3} green
polyop.setvertcolor n 0 #{6,8} black

format "red:%\n" (polyop.getvertsbycolor n red 0 0 0 channel:0)
format "blue:%\n" (polyop.getvertsbycolor n blue 0 0 0 channel:0)
format "green:%\n" (polyop.getvertsbycolor n green 0 0 0 channel:0)

thorsten hartmann
12 December 2010, 10:22 AM
Hi Denis,

thank you to the code. From time to time, i understand more and more. :beer:

CGTalk Moderation
12 December 2010, 10:22 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.