Color a list of geometries with unique colors

I am trying to color individual vertical elements in a list, however i am unable to figure out the script. I am sort of stuck.

They have different heights, following a curve, for a facade design. I want them to be colored individually. How can i do this?

Hello
You can generate colors using gradiant then randomize the list of colors.
You can also choose n color then use that

Hey Laurent

The issue with that script is that it didn’t color the geometries as one element. If i use explode brep and list the surfaces, it only works partially, by coloring them all as one color. My main issue is trying to understand how to list all of the highlighted geometries and assign to every one of them one color, maybe coming from some sort of color series script.

It’s like for every vertical element, grasshopper would just fill one, goes to the next vertical element and then shifts values of the previous color by a certain number (if we use RGB for example).

I don’t really see where is the problem in doing what you want. It could be useful to have more details and a script with the list of objetcs you want to color
Something like that
I have n objects I want to put n differents colors
I have n objects i want to color with m colours and i dont want 2 same asjacent colours

Other questions
Colors from a palette a gradiant … ?

I am sure we could find a solution

My ncolor deconstruct a brep just to have a topology. In your case the topology is just pile n is linked to n-1 and n+1

So here an example,
so let say I have Brep, but it could be whatever object you want. Objects are ordered on a circle, they have a number 0, 1 … to 49. Object 0 is connected to 49 and 1

So you just have to put this connectivity in my component
Generate M colors and say to the algorithm you need M colors.


NextColorNotRandom must be set to false.
image
Because if set to true, the algorithm will minimize the number of color

With 50 objects just 2 colors needed


With 51 objects 3 colors needed, here the toggle to true

and here toggle to false

nColorsObjects.gh (17.8 KB)

3 Likes

Wow, thank you Laurent! I will give it a shot and reply back as soon as possible!

It works great! i would like to thank you again for sharing your explanation. I’m trying to take this one step further to randomly color one face of every rectangle. Deconstructing brep then defining the faces as an item list doesn’t seem to do the trick. Maybe its a matter of volume (i.e. depth) of the object or perhaps it’s something else.

It is just a matter of topology, my tool just work with integers. So you number all faces with an unique integer then you do the topology. It is up to you to decide which object is related to others objects
See on green panel
Branch {0} relate to the object n° 0 related to object 1 and 49
Branch {1} relate to the object n° 1 related to object 0 and 2

1 Like

Hello Laurent,

I was trying to assign the surfaces but I don’t know how. I am not an expert in Grasshopper. My surfaces remain as N=1 after i desconstruct brep to list the surfaces i need to be colored. In the end they end up as one color which is frustrating me. Any tips on how to assign unique numbers to series of surfaces?

image
I am also getting multiple surfaces on top of each other for some reason. And I am unable to understand why …

I think the best think is to post a file (without all geometries) with the grasshopper script.

Laurent.gh (123.9 KB)
Here is the script

Many errors => use panel to follow the data
List length count the number in a list, if data is grafted (in datatree) there is just one element in each branch.
image
=> flatten
image

Color 0 and 2 are the same

Use Swatch to make some unique color more easily
image

Panels are not ordered
image

1 Like

here a version that sort the faces. I extracted the 2 biggest faces, sorted on X. But if not aligned it will not be a good thing to do.


I also added 2 more connections so on a same plank the faces will not have the same color and also on the next plank.
Laurent_LD.gh (127.2 KB)

2 Likes

Thank you so much, Laurent! This script acutally helps a lot! It’s a much more flexible solution, will definitely be learning from it :slight_smile: