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?


I found the solution:


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


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.