pymel.core.rendering.viewFit

viewFit(*args, **kwargs)

The viewFit command positions the specified camera so its point-of-view contains all selected objects other than itself. If no objects are selected, everything is fit to the view (excepting cameras, lights, and sketching plannes). The fit- factor, if specified, determines how much of the view should be filled. If a camera is not specified, the camera in the active view will be used. After the camera is moved, its center of interest is set to the center of the bounding box of the objects.

Flags:

Long Name / Short Name Argument Types Properties
allObjects / all bool ../../../_images/create.gif
  Specifies that all objects are to be fit regardless of the active list.
animate / an bool ../../../_images/create.gif
  Specifies that the transition between camera positions should be animated.
center / c bool ../../../_images/create.gif
  Specifies that the camera moves to the center of the selected object, but does not move the camera closer.
fitFactor / f float ../../../_images/create.gif
  Specifies how much of the view should be filled with the fitteditems.
namespace / ns unicode ../../../_images/create.gif
  Specifies a namespace that should be excluded. All objects in the specified namespace will be excluded from the fit process. Flag can have multiple arguments, passed either as a tuple or a list.
panel / p unicode  
   

Derived from mel command maya.cmds.viewFit

Example:

import pymel.core as pm

# Position the active camera to view the active objects
pm.viewFit()

# Position cameraShape-1 to view all objects
pm.viewFit( 'cameraShape1', all=True )

# Fill 50 percent of the active view with active objects
pm.viewFit( f=0.5 )

pm.viewFit( all=True )