The viewHeadOn command positions the specified camera so it is looking “down” the normal of the live object, and fitted to the live object. If the live object is a surface, an arbitrary normal is chosen.
Derived from mel command maya.cmds.viewHeadOn
Example:
import pymel.core as pm
# Create a new camera
cam = pm.camera()
camera = cam[0]
# Create a polygonal cone, rotate it, make it live
object = pm.polyCone( ax=(0, 1, 0) )
pm.rotate( 15, 30, 45 )
pm.makeLive( object[0] )
pm.viewHeadOn( camera )
pm.makeLive( none=True )