Hotkeys for changing texture brush strength

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

Post Reply
Posts: 0
Joined: Tue Jul 30, 2013 8:23 pm

Hotkeys for changing texture brush strength

Post by DethRaid »

I recently came into possession of a SummaSketch II tablet, complete with a 16-button mouse. I'm looking for a way to integrate that with Blender.

My idea is to have the buttons mapped to things I'd normally do in the Texture Paint window. This includes change brush color, change brush strength, change brush, move the viewport, etc. The driver I'm using lets my map each button on the SummaSketch mouse to a key or combination of keys on the keyboard. So, I figured I could write a Python script which would change brush characteristics when certain keys are pressed, then make sure those keys exist on the SummaSketch mouse.

A bit of digging around on the internet revealed the modal() function. This function would seem to fit my needs, except that my script doesn't actually work. When I hit "run script" in the Text Editor and press the keys that the script is supposed to recognize, nothing happens. When I load the script through the Addons dialogue, nothing happens. The script is posted below. What am I missing?

Code: Select all

import bpy

bl_info = {
    "name": "Summa Sketch Integrator",
    "category": "Object"

class SummaSketchIntegrator(bpy.types.Operator):
    """Move an object with the mouse, example"""
    bl_idname = "object.summa_sketch_integrator"
    bl_label = "SummaSketchIntegrator"

    def modal(self, context, event):
        print('RUNNING MODAL')
        if event.type in {'E'}:
            for brush in
                brush.strength = 0.25

        elif event.type in {'G'}:
            for brush in
                brush.strength = 0.5

        elif event.type in {'S'}:
            for brush in
                brush.strength = 0.75
        elif event.type in {'R'}:
            for brush in
                brush.strength = 1

        return {'RUNNING_MODAL'}

    def invoke(self, context, event):
        print( 'INVOKE' )
        return {'RUNNING_MODAL'}

def register():
    print( "Hello World" )

def unregister():

if __name__ == "__main__":

Post Reply