19
$\begingroup$

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?

$\endgroup$
0

6 Answers 6

15
$\begingroup$

You can use Alt+F to centre the view to your mouse pointer.

The exact behaviour you requested can be achieved with a little Python. Run the following in the text editor and add a view3d.view_center_origin key-binding of your choosing.

import bpy

class VIEW3D_OT_View_Center_Origin(bpy.types.Operator):
    bl_idname = "view3d.view_center_origin"
    bl_label = "Center view to origin"

    def invoke(self, context, event):
        v3d = context.space_data
        if v3d.type == "VIEW_3D":
            rv3d = v3d.region_3d
            current_cloc = v3d.cursor_location.xyz
            v3d.cursor_location = (0, 0, 0)
            bpy.ops.view3d.view_center_cursor()
            v3d.cursor_location = current_cloc
        return {'FINISHED'}

if __name__ == "__main__":
    bpy.utils.register_class(VIEW3D_OT_View_Center_Origin)
$\endgroup$
4
  • $\begingroup$ The Aldrick answer was the MUST answer! Great thanks to Aldrick! I have made THE add-on about this question with his code: blenderartists.org/forum/… The keymap is preseted on "ctrl shift Numpad ." but I can change it for you. Bye Spirou4D $\endgroup$
    – Spirou4D
    Commented Jun 13, 2013 at 7:05
  • $\begingroup$ @Spirou4D Glad you found it useful. $\endgroup$
    – Aldrik
    Commented Jun 21, 2013 at 17:27
  • $\begingroup$ @Spirou4D and Aldrik: Thank you for the code/addon! This does exactly what I was looking for, very simply. Note to Spirou4D: I ended up changing the keymap to Ctrl+Shift+. (the normal period) in order to work better with how my laptop emulates the numpad. $\endgroup$
    – Gwen
    Commented Jun 21, 2013 at 23:50
  • $\begingroup$ In the case where v3d.type != "VIEW_3D", how can I change that using a script? $\endgroup$
    – Noam Peled
    Commented Apr 17, 2018 at 15:50
14
$\begingroup$

This is not the ideal way if there is a built in function, but you could do this:

  1. Create an empty at the cursors postion.   You can do this with Shift + A EmptyPlain Axes. (Or really anything in the Empty menu, such as Box or Circle.)
  2. Snap the cursor to the origin.  Shift + C.
  3. Center view to cursor.  Alt + Home.
  4. Select the empty you made and snap the cursor to the selection.  Shift + S and then Snap to Selected in the menu.


Alternatively, (based off of Jonathan's answer), you could:

  1. Add an empty at the origin.  Shift + A EmptyPlain Axes, then set the location to 0,0,0 in the redo menu (F6)
  2. Center view to the Empty.  . (on the numpad.)

This second method is a lot faster and you only have to add an empty once, but the first one does help if you accidentally move the cursor position.

$\endgroup$
1
  • 7
    $\begingroup$ +1 You could then make a script to do all this and also delete the empty at the end. $\endgroup$
    – Daniel
    Commented May 27, 2013 at 6:53
8
$\begingroup$

If you want to center the view to the current selection then you can use Numpad.. This will center the view and zoom to the current selection.

However this will not work if you do not have a selected object.

$\endgroup$
2
$\begingroup$

You could just press the Home button

$\endgroup$
3
  • 1
    $\begingroup$ Hi, on this site, we appreciate answers with good detail. If you could at least explain what this does it would be helpful. $\endgroup$ Commented May 30, 2013 at 4:24
  • $\begingroup$ This doesn't do quite what I'm looking for, since I want to move the view so that it is centered on the origin. What Home does is center the view around the bounding box center for all of the objects, which probably will not quite line up with the origin. $\endgroup$
    – Gwen
    Commented May 31, 2013 at 3:54
  • $\begingroup$ I found this very useful....thank you. $\endgroup$
    – Fiddy Bux
    Commented Apr 12, 2019 at 22:13
0
$\begingroup$

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.

$\endgroup$
0
$\begingroup$

@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:

def center_view():
    current_cursor_pos = tuple(bpy.context.scene.cursor_location)
    bpy.context.scene.cursor_location = (0, 0, 0)
    for v3d_context in get_view3d_context():
        try:
            bpy.ops.view3d.view_center_cursor(v3d_context)
            break
        except Exception as e:
            print('Wrong context')
    bpy.context.scene.cursor_location = current_cursor_pos

def get_view3d_context():
    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
                    yield override
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .