The shortcut I have always used to center my view is Shift +C, then Alt + Home. This moves the 3D cursor to the origin, then centers the view on the 3D cursor.
However, in some situations, I want to center the view at the origin without affecting the location of the 3D cursor, which I have set for rotation purposes, etc. Is there a different shortcut I can use instead?
I don't mean to add a redundant answer, but to improve on what Jonathan said, I would suggest selecting all objects with A, then pressing ..
The reason for this is that sometimes when you select a particular object and then centre the view, it leaves some objects out of sight. If you want to be able to view everything in your scene as if you had pressed CTRL+C, you will need to select all the objects.
@Aldrick answer is great, but it doesn't work in case v3d.type != "VIEW_3D", like in my case where my addon is in the Graph panel. I could bypass this problem using the following script:
current_cursor_pos = tuple(bpy.context.scene.cursor_location)
bpy.context.scene.cursor_location = (0, 0, 0)
for v3d_context in get_view3d_context():
except Exception as e:
bpy.context.scene.cursor_location = current_cursor_pos
for screen in bpy.data.screens:
for area in screen.areas:
for region in area.regions:
if region.type == 'WINDOW':
override = bpy.context.copy()
override['area'] = area
override["region"] = region