How to join surfaces with different colors assigned without unifying them

How to join surfaces with different colors assigned without unifying into one single color?
I have a few colors assigned to polysurface. Grouping allows me to keep colors but joining always forces me to have only one color. How to join polysurface solid and keep many colors inside?

This is a bit tricky, because colors are assigned two different ways. Normally colors are assigned per object - for example all of the individual surfaces in a joined polysurface have the same color. However, as of V7, it has been possible to assign different colors to individual surfaces in a polysurface. This is called per-face color.

It would be interesting if Join had an option to allow per-object color to become per-face color when joining surfaces. But this option does not exist (yet). So individual surfaces that have had a color assigned per-object (the normal way) will still join into one single colored object. However, if beforehand they are assigned a per-face color, they will join and retain the original per-face colors.

So the trick is to assign surfaces per-face colors… You can do this on single surfaces by ctrl+shift clicking on the surface and then assigning the color. Then it is assigned per-face and can be joined other surfaces without changing its color.

However, for existing surfaces that already have a color assigned per-object, this is not practical. I think it should be possible to do this via scripting though.

1 Like

If you have hundreds of surfaces in a few different colors then picking every one by hand would be not fun. This is work for nothing cause they are already assigned.

Run with UseBrepColor=Yes to set all the face colors to their polysurface (object) color. If the object color is By Layer, the faces are assigned the current layer color.

1 Like

Yes. I am working on a script that should be able to change per-object colors into per-face colors, but I didn’t have time to finish yet… Maybe today, but a lot of other stuff going on at the moment. I also discovered a Rhino bug in this regard - the one mentioned in the other thread concerning joining of surfaces with per-face colors assigned and those without.

1 Like

Should I select all polysurfaces which I would like to join and will it join it with preserving colors? Am I right?

I did my job with grouping because I wanted to export meshes with assigned colors. It’s far from perfect but I needed to give that job to the client and I had no time to wait or to click surfaces one after another. Thanks for your help. That script will be helpful for many people with the same problem for sure. Because it`s not super fancy need to join surfaces with preserving colors.

Thanks for your work and help for the community guys!!!

Edit: I wanted to have it joined to have a consistent polygonal shell with colors which will help me to do UV in other software (Modo).

OK, here is a test version. For all selected surfaces/polysurfaces, it assigns a per-face color based on the following criteria:

  1. If a single surface or an individual face in a polysurface already has a per-face color assigned, it is preserved.

  2. If the surface or polysurface face does not have a per-face color assigned and is color by layer, it assigns the layer color to the face as per-face.

  3. If the surface or polysurface face does not have a per-face color assigned and is color by object, it assigns the object color to the face as per-face.

It includes the workaround for a bug I found, but I have not tested it extensively. If you find cases where it does not work, let me know (sample file) and I will see what can be fixed. (1.6 KB)

In principle, once the script is run on the objects they should be able to be joined with the normal Join command and keep their original colors. Of course, if you want to return to by layer or by object, you will need to run the command RemovePerFaceColors in Rhino.