Is it possible to remap a key to call more than one operator at a time, or to execute a python script?
In my workflow I need to use two operators, one after the other:
Set the 3D cursor to selection, followed by set origin to 3D cursor.
I never use the 0 key to switch layers,so I thought it would be faster to make it "set origin to selection", but i don't know how to make it call those two in one go.
bpy.ops.view3d.snap_cursor_to_selected()
bpy.ops.object.origin_set(type='ORIGIN_CURSOR')
If this works it would save me exactly 6 key presses:
Shift+S ,4, tab to go to object mode,Shiftctrlaltc,3,tab to go back to edit mode.
Thanks for any input
Edit : This works when executed from a text editor, now i just need to figure out a way to execute it with the 0 key.
import bpy
for area in bpy.context.screen.areas:
if area.type == 'VIEW_3D':
context = bpy.context.copy()
context['area'] = area
context['region'] = area.regions[-1]
bpy.ops.view3d.snap_cursor_to_selected(context)
bpy.ops.object.editmode_toggle()
bpy.ops.object.origin_set(type='ORIGIN_CURSOR')
bpy.ops.object.editmode_toggle()
break