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!
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!
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()