Randomising set number of colors to a number of objects

Hi Everyone.

I am looking for a method or a script that will help me assign colors that I set before to a number of objects. Lets imagine I have 100 panels I want to randomly color with 3 colors. I would not like to do it by hand really especially if the number grows to a 1000 or so. This way I could as well divide evenly all the panels into 3 groups. I found many scripts that randomise color into all the objects but there is no control over it. I know it can be done in grasshopper although I am having difficulty doing so.

Thanx for all the help !
J

Hello
Did you look at this link ? It is grasshopper but seems to solve your problem

1 Like

Here is a quickie Python script that does what (I think) you want…

  1. Select a bunch of objects
  2. The color picker dialog will come up
  3. Pick a color you want
  4. Keep picking more colors to add to the set - the dialog will continue to come up until you hit the esc key or the cancel button in the dialog. No limit on how many
  5. Colors will be randomly attributed to the selected objects from the set of colors you chose.

ColorObjectsFromColorSetRandom.py (745 Bytes)

Works in Windows Rhino. I’ve not tested it on Mac, I hope it does as well. Just not sure because the color picker dialog in Mac Rhino is non-modal…

3 Likes

Thank you guys !

I’ve tried to modify grasshopper code but could not manage it. In the future I will try to set up randomisation of colors with possible options to control it a little bit ie 30% of color 1 etc. First of all need to find some time to learn basics of grasshopper.

Helvetosaur thank you so much ! This is exactly what I’ve been looking for. It will make me save a lot of time.

Jarek

Hello Helvertosaur,
I know this is an old topic, but would be great if you can still help (or if anybody does).
Can I skip the color picking and just randomly assign different colors for the same number of objects I picked up? For example, I select 5 objects, and Rhino, automatically and randomly, assigns them 5 different colors. I hope the goal I’m looking for is clear. I’m asking this because sometimes I get files with 30 and more pieces inside in just one single layer :sweat_smile:

thanks everybody and model on,
my best,

Marco

Sure… Here are a couple

Simple random RGB:
RandomColor.py (406 Bytes)

Random colors with 100% saturation:
RandomSaturatedColor.py (430 Bytes)

Random light color (good for users with darker viewport backgrounds):
RandomLightColor.py (541 Bytes)

3 Likes

Hi, I want to create 2 colors or multiple colors on 1 object, can I?

Hi Helvetosaur,

Wonderful scripts here… Wondering if HSVA can be combined into 1 script with control for each step?
e.g., randomise Hue + or - x degrees, saturation between 50-100, value between 0 - 50, alpha all 100?

This could be super helpful if it could also be applied for selected layers as well…

-Jeremy

This is a truly powerful script <3 thank you.

  1. Is it possible so that when the colour wheel comes up, that it could remember the previously set color? That means that one could quickly change luminance etc of the same previous colour.

  2. Can these scripts be applied to groups? That is, using the group like an object so that all the colours within the group are given one colour?

-Jeremy