Zoom out to view whole object after getting to Bottom Orthographic View

I would like to zoom out to view the whole object, after changing to Bottom Orthographic View. The following codes could only change to Bottom Orthographic View, but no clue how to zoom out:

area_type = 'VIEW_3D'
areas  = [area for area in bpy.context.window.screen.areas if area.type == area_type]

override = {
    'window': bpy.context.window,
    'screen': bpy.context.window.screen,
    'area': areas[0],
    'region': [region for region in areas[0].regions if region.type == 'WINDOW'][0],
}

bpy.ops.view3d.view_axis(override, type='BOTTOM', align_active=True)

Aware! The scene collection has only one object, without camera and light. The Blender version is 2.8.

Add this line to the bottom of your script:

bpy.ops.view3d.view_selected(override, use_all_regions=False)

Blender has an operator, found in View > Frame Selected that will focus the viewport on the selected object.
Adding this operator to the end of your script will tell Blender to fit the active object within the viewport bounds.

1 Like

You are right, my fault saying you are wrong. You are truly a genius.

1 Like