0

Hello I want to change the material of some objects, since it is not applied the material, I want you to apply via code in python, is a group of three materials that is just an object, I want wif the cube gets a material a sphere with another material different from the cube, and a cone with another material different from the sphere and cube.

Sielxm3d
  • 59
  • 1
  • 2
  • 9
  • 3
    creating and assigning materials is covered here If you are using cycles then adding nodes to a material is also covered here – sambler Jan 18 '16 at 09:03
  • This question could be clearer. Your other question was about doing Booleans and I'd like to know if this question is a continuation of that. Do you mean you want to preserve the unique materials after doing a Boolean? so the resulting object (after boolean) has several materials given by the surfaces of the objects involved in the booleans? – zeffii Jan 18 '16 at 09:52
  • do you mean this kind of material assignment? : http://i.stack.imgur.com/V0iBe.png – zeffii Jan 18 '16 at 10:00

1 Answers1

1

You need a reference to the material and the object.

import bpy

# alias as D because we'll use it alot.
D = bpy.data

red_material = D.materials["Red_Material"]
cube = D.objects['Cube']
cube.active_material = red_material
zeffii
  • 39,634
  • 9
  • 103
  • 186