Notifications
Clear all

[Closed] Setting Vertex Colors in MAXScript

I need to be able to set vertex colors programmatically. Here is an example of the code I am trying to run and the error that I get. Can anyone help me out?

verts = #([1,1,0],[-1,1,0],[-1,-1,0],[1,-1,0])
faces = #([1,2,3],[1,3,4])
m = mesh vertices:verts faces:faces
setvertcolor m 1 [1,50,200]

– Runtime error: Mesh Color-per-vertex vertex index out of range: 1

2 Replies

Have a look at setnumcpvverts in the reference.

verts = #([1,1,0],[-1,1,0],[-1,-1,0],[1,-1,0])
faces = #([1,2,3],[1,3,4])
m = mesh vertices:verts faces:faces
setNumCPVVerts m m.numverts
defaultVCFaces m
setvertcolor m 1 [1,50,200]

Thank you for your help dutch delight, that did the trick.