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 !

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…

1 Like

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.