I am trying to automate the task of creating an eraser brush in blender via python, as part of another operator.
I want to look for brush named 'ERASER' and switch to it, or create one and make it the active brush if not.
I found a few things online, but it looks more like sculpt brushes are easier to handle data wise than image paint/texture paint brushes. I am hoping someone might point me in the correct way of handling this.
Thanks in advance for help.
Current code snippet:
class GenericOper(bpy.types.Operator):
"""Generic Operator"""
bl_idname = "object.generic_operator"
bl_label = "Generic Operator Template"
bl_options = { 'REGISTER', 'UNDO' }
def execute(self, context):
scene = context.scene
#new code
#bpy.ops.paint.texture_paint_toggle()
bpy.ops.paint.brush_select(paint_mode='ACTIVE', texture_paint_tool='DRAW')
bpy.ops.brush.add()
bpy.data.brushes["TexDraw.001"].name="ERASER"
bpy.context.scene.tool_settings.unified_paint_settings.use_pressure_size = False
bpy.data.brushes["ERASER"].use_pressure_strength = False
bpy.data.brushes["ERASER"].blend = 'ERASE_ALPHA'
return {'FINISHED'}