3

I would like to create a shortcut to activate/deactivate (Occlude, Cull and Normal) checkboxes at the same in Texture Paint mode with a single key. Is it possible? or is scripting required for something like that?

Thanks!

gandalf3
  • 157,169
  • 58
  • 601
  • 1,133
Zafio
  • 254
  • 1
  • 7
  • Related: http://blender.stackexchange.com/q/17822/599 – gandalf3 Jun 19 '15 at 19:30
  • You can do this by making a custom operator. It isn't too hard, see http://blender.stackexchange.com/a/5388/599 for an example. – gandalf3 Jun 19 '15 at 19:32
  • Thanks gandalf3! Although, after one hour without success I can't say it isn't too hard... but I'll keep trying! – Zafio Jun 19 '15 at 22:11

1 Answers1

3

Here's the script to do it. It currently toggles Backface Culling, MatCap, and Ambient Occlusion. I don't think there's a Normal toggle in object mode. did you mean in Edit Mode, toggling Face/Vertex Normals?

I've set up a key command to use SHIFT+SPACE but you can change that if you want.

import bpy

def main(context):

    area = bpy.context.area

    if area.type == 'VIEW_3D':
        bpy.context.space_data.show_backface_culling = not bpy.context.space_data.show_backface_culling
        bpy.context.space_data.use_matcap = not bpy.context.space_data.use_matcap
        bpy.context.space_data.fx_settings.use_ssao = not bpy.context.space_data.fx_settings.use_ssao



class opToggleCheckboxes(bpy.types.Operator):
    """Tooltip"""
    bl_idname = "object.toggle_checkboxes"
    bl_label = "Toggle Checkboxes"

    @classmethod
    def poll(cls, context):
        return context.active_object is not None

    def execute(self, context):
        main(context)
        return {'FINISHED'}

addon_keymaps = []


def register():
    bpy.utils.register_class(opToggleCheckboxes)

    # handle the keymap
    wm = bpy.context.window_manager
    km = wm.keyconfigs.active.keymaps['3D View']
    kmi = km.keymap_items.new(opToggleCheckboxes.bl_idname, 'SPACE', 'PRESS', shift=True)
    addon_keymaps.append(km)


def unregister():
    bpy.utils.unregister_class(opToggleCheckboxes)

    # handle the keymap
    wm = bpy.context.window_manager
    for km in addon_keymaps:
        wm.keyconfigs.addon.keymaps.remove(km)
    # clear the list
    del addon_keymaps[:]



if __name__ == "__main__":
    register()
Todd McIntosh
  • 9,421
  • 25
  • 50
  • Thank you Todd! The options I meant were from Project Paint panel in Texture Paint mode, but that code it was easy to change! – Zafio Jun 23 '15 at 10:48
  • With some extra help from Diego Quevedo made a tiny Addon, that also changes the cursor color when project paint options are inactive: http://blenderartists.org/forum/showthread.php?374475-Addon-Project-Paint-Toggle – Zafio Jun 24 '15 at 18:53