0

I have one wall in the project I am working on. I want the color of this wall to change when I run the code. I did research but couldn't find it.

import random

rgb = () for i in range(3) : rgb += ((random.randrange(1, 10, 3) /10),)

mat.diffuse_color = rgb

  • 2
  • Not exactly, I want the selected object to change, so the duplicated objects change. – fighterpilot Oct 14 '21 at 13:49
  • 1
    Could you please edit your question and add all relevant details to understand your goal? Hard to guess what you want based on the provided code, you're just assigning something to the viewport's material color. Do you would like to change the viewport material color or the base color of the shader? "Radom Color to 1 Object" suggests (to me) that you'd like to randomize the color of one object or mesh (hence the link to the other question, principles are the same). Can you provide a minified blend file or at least a screenshot to see your geometry and what kind of dupes you have? – brockmann Oct 14 '21 at 14:01
  • It's fairly easy to generate a random color. The question I have is what do you want to use to trigger the random color to change. In python it might be a button on a panel or a custom property that you change, or even something driven by the frame number of an animation. – Marty Fouts Oct 14 '21 at 14:09

0 Answers0