How to Change Brush Texture file through Python

I’ve looked at the API for hours and I still can’t figure out how to change the image used as a brush in texture mode through python. I need to be able to do this for my script.

Say I have an image loaded into blender called spam.jpg and the texture is called ‘spam’

How do I make spam the texture I use as my brush in texture mode through python? Thanks!

Haha, wouldn’t you know it. 10mins after posting I figured it out:


bpy.data.brushes['TexDraw'].texture = bpy.data.textures['spam']

Thanks guys.

Moved from “General Forums > Blender and CG Discussions” to “Coding > Python Support”