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.


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

elif event.type in {'MIDDLEMOUSE'}:
    if event.alt:

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?


1 Answer 1


I found the solution:


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


You must log in to answer this question.

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