3
$\begingroup$

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!

$\endgroup$
3
$\begingroup$

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()
| improve this answer | |
$\endgroup$
  • $\begingroup$ Thank you Todd! The options I meant were from Project Paint panel in Texture Paint mode, but that code it was easy to change! $\endgroup$ – Zafio Jun 23 '15 at 10:48
  • $\begingroup$ With some extra help from Diego Quevedo made a tiny Addon, that also changes the cursor color when project paint options are inactive: blenderartists.org/forum/… $\endgroup$ – Zafio Jun 24 '15 at 18:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.