I'm fairly new to blender scripting and I'm having some trouble figuring out the context in which every command must be to work. My code looks like this:
bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY', center='MEDIAN')
bpy.context.area.type = 'VIEW_3D'
bpy.ops.view3d.snap_selected_to_cursor(use_offset=False)
bpy.ops.object.editmode_toggle()
bpy.ops.transform.translate(value=(0, 20.6551, 0), orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(False, True, False), mirror=True, use_proportional_edit=False, proportional_edit_falloff='SMOOTH', proportional_size=1, use_proportional_connected=False, use_proportional_projected=False)
I've figured out view3d
for the snap, but as soon as I want to move it in edit mode it closes blender
I assume I need to set the context for every line but I have no idea where to start looking for what command needs what context.