# Make camera move to frame selected objects
def cam_view_selection(cam = bpy.context.scene.camera):
    '''Move given camera to frame selected objects with Ops viewSelect method'''
    #set active camera
    bpy.context.scene.camera = cam
    #view selected
    for area in bpy.context.screen.areas:
        if area.type == 'VIEW_3D':
            ctx = bpy.context.copy()
            ctx['area'] = area
            ctx['region'] = area.regions[-1]
            #bpy.ops.view3d.view_selected(ctx)            # points view
            bpy.ops.view3d.camera_to_view_selected(ctx)   # points camera

cam_view_selection()