Notifications
Clear all

[Closed] vertex color changed by script

 rdg

hello,

I painted a poly object using the VertexPaint-Modifier.
Now I have to change the colors …

I converted the object to Editable Mesh and I wrote a “script” to change the vertex colors:

theObj = $unterkiefer_mesh
  nVerts = theObj.numverts
  for i=1 to nVerts do(
  vert = getVertColor theObj i
  	if vert != color 255 255 255 then (
  	-- print i
  	setVertColor theObj i  (color 234 69 96)
  	)
  )

but not all vertices are processed [1].
How can I change all the vertices that aren’t “white” to a different color?

Georg


[1] only a few verts changed color:

3 Replies
 rdg

I solved my problem with “Render to Texture” and Photoshop.

I would be grateful if anyone could point me in the direction how to change all vertex colors with a script.

Maybe I don’t understand the way a mesh works?

Georg

didnt test it but maybe this is your problem:
From the help file:

“There can be more or less texture and color vertices than there are mesh vertices “

so instead using:

                                theObj.numverts

you might use:

getNumCPVVerts

 rdg

Thank you logotomie!
I just quickliy scanned the helpfile for keywords, but didn’t read it.

Here is the working code:


 -- changes non-white vertices to pink color
 theObj = $oberkiefer
 convertToMesh theObj
 --nVerts = theObj.numverts
 nVerts = getNumCPVVerts theObj
 for i=1 to nVerts do(
 vert = getVertColor theObj i
 	if vert != color 255 255 255 then (
 	--print i
 	setVertColor theObj i  (color 234 69 96)
 	)
 )

Georg