Disable per-vertex mesh colour

Hi all,

I have a mesh which has per-vertex colours. I seem unable to quickly turn off these colours in Rhino. Is this possible or is there a specific workflow that I have to follow to see my mesh without any colours?
Cheers!

Hi Geert - you can remove the vertex colors with RebuildMesh, but that is pretty extreme I guess. I do not yet see a good way to toggle the display of the colors though…

-Pascal

Thanks for your answer Pascal, but that is indeed too extreme since I want to keep the colours. I also have a texture, so I thought of creating a new material (light grey). However, If I assign that to the mesh, I loose my original texture…

Hi Geert - can you post, or send me via private message, an example?

-Pascal

Here is a script to toggle mesh vertex colors. MeshVertexColorToggle.py (2.1 KB)

Note that if you first hide the vertex colors, do not modify the mesh or they cannot be restored.

c.

Very nice, @clement!

-Pascal

1 Like

Thanks @Pascal. I´ve been surprised how many color values i can store in the user strings. Is there a limit i should watch out for ?

c.

Hi Clement - I don’t know about that. @dale - do you have an idea?

-Pascal

Hi Clement,
Another way would be to store the complete mesh in the geometry user dictionary.

http://4.rhino3d.com/5/rhinocommon/?topic=html/P_Rhino_Runtime_CommonObject_UserDictionary.htm

I’m on my phone so I cannot provide an example but let me know if you want to me post a simple setup. I’ve used it to store different breps that could be toggled. In my case a surface and it’s offset into a sheet with thickness that can be toggled between.

-Willem

1 Like

@Willem, yes an example would be great. I think it might be very helpful if i could get rid of the color conversion maybe ?

c.

Cheers Clement. Works as a charm. Highly appreciated!
Geert

@pascal, @Willem, @Rawli1836,

since i´ve been unsure how many vertex colors can be stored in a user string, i´ve changed the code to use a user dictionary as Willem suggested. (Thanks by the way for mentioning it, it seems much more comfortable).

I´m still storing the vertex colors as integer values using a System.Array. As far as i understand the maximum amount of vertex color integers the Array can store under 32bit equals 4.294.967.295 colors. (See Remarks section here) I hope this is enough :wink:

Updated script, i´ll leave the one above for reference: MeshVertexColorToggle2.py (2.3 KB)

c.

Hi Clement,

Here you go.
MeshVertexColorToggle_wd.py (1.8 KB)
Some sidenotes:
A copy of the geometry is stored, so any transformations by the user on the mesh after the toggle are discarded. ( eg: Move the mesh and toggle will get the old position)
To only swap vertexcolors as is the case here, it would be better to only get the stored mesh’s vertex colors and apply them to the current mesh. In that case, your setup is better ( or a colored pointcloud maybe).

HTH
-WIllem

1 Like

Thanks @Willem for the example, i like it as it does not require iterating over the colors, which does make the toggle a bit faster on very large meshes.

c.

There is no limit on how large the string can be…

Thanks @dale. Good to know, Rhino has no limits :wink:

c.

Hi Sir.
You can also use grasshopper. You deconstruct mesh at first, then construct mesh from deconstruct component data, but don’t connect color data. Good Luck:shamrock::shamrock::shamrock:

@aminaminkhani,

this thread is about how to disable and later re-enable mesh vertex colors which could be done with a script or by adjusting the display mode properties. To get rid of mesh vertex colors, you might use the _RebuildMesh command without having the mesh preselected. Then set the command options like below:

_PreserveTextureCoordinates=_Yes _PreserveVertexColors=_No

and select the mesh. This does remove the mesh vertex colors completely.

_
c.