1
$\begingroup$

I am trying to center the view to the mouse point in a Python modal operator. However, I just couldn't find the right operator in the API documentation.

https://docs.blender.org/api/current/bpy.ops.view3d.html

I found bpy.ops.view3d.view_selected() and using it like this

elif event.type in {'MIDDLEMOUSE'}:
    if event.alt:
        bpy.ops.view3d.view_selected()

does center on the selected object which is a similar operation but not exactly what I wanted. Basically I would like to perform the same operation Blender is calling when pressing ALT+MIDDLEMOUSE in the 3D viewport ("Center View to Mouse").

Anyone knows the right operator for this?

$\endgroup$

1 Answer 1

1
$\begingroup$

I found the solution:

bpy.ops.view3d.view_center_cursor()

See https://docs.blender.org/api/current/bpy.ops.view3d.html#bpy.ops.view3d.view_center_cursor

$\endgroup$

You must log in to answer this question.

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