Normally, with most actions that you want to script with Python there is a pop-up tooltip that shows you the function that you want to use. However, for viewport navigation there are no pop-ups, you use the mouse directly for everything (scrolling to zoom, middle-click-and-drag to pan). How can I navigate the viewport with Python?
I would suggest not to call operators at all, these are rather cumbersome way to interact with the view, Instead manipulate the view directly.
If you write an operator you can access the viewport like this...
v3d = context.space_data rv3d = v3d.region_3d rv3d.view_location.x += 1.0
You may also want to treat the view as a 4x4 matrix since in some cases this is more convenient since you can multiply it with other matrices to combine transformations, accessible from the
To get started you may want to try things out in the python console...
For this you need to specify the absolute path to the 3D region.
Scripting screen layout you can run this from the console or editor...
rv3d = bpy.context.screen.areas.spaces.region_3d rv3d.view_rotation.rotate(Euler((0, 0, 0.1))) rv3d.view_location.x += 1.0 rv3d.view_distance -= 1.0
We have a template of an operator that edits the view in the text editor
Operator Modal View3D
Hover over the menu items, the options/commands are there, Go to the 3d view header then View → Navigation. You can hover over a menu item and use Ctrl + C to copy the command to your clipboard.
For example, to pan to the right, you can use
bpy.ops.view3d.view_pan(type='PANRIGHT') and to zoom out you can use
I don't think you will be able to move very naturally however, not quite in the way you want to at least.