create mirror material using python (2.5+)

Hi all,

What’s the best way to enable reflections in a material (using python, not the GUI)?

It’s not possible to just enable it using a property (like Material.use_transparency). I guess you should use the MaterialRayTraceMirror object, but I can’t get that to work. Any ideas?

Thanks a lot

Found it myself, so in case someone finds this post later on, here is what I had to do:

First of all you have to have a material (duh):
mat = bpy.data.materials.new(‘name_here’)

In stead of creating a MaterialRayTraceMirrorobject and trying to link that to the material, you just use the read-only property ‘raytrace_mirror’.

So:
mat.raytrace_mirror.depth = 5 sets the mirroring-depth to 5
set any other property like this and then use

mat.raytrace_mirror.use = True

That’s the same as ticking the checkbox in the Materials-panel.

Hope it helps