Maya: Reset Perspective Camera
Description
If you ever find your self in need of resetting your perspective camera the following script will reset your camera back to the default state.
How It Works
The script below will find the existing perspective camera, delete it and create a brand new camera to replace it.
Application: Maya
Application Compatibility: 2015 and up.
Script Type: Python
Always save your file before running any script.
import pymel.core as pm
# Check to see if perspective camera exists
if pm.objExists("|persp"):
# Gets the perspective camera and sets it to not be a startup camera then deletes it
perspective_camera = pm.PyNode("|persp")
pm.camera(perspective_camera, e=True, startupCamera = False)
pm.delete(perspective_camera)
# Creates a new camera renames it perspective, hides it, and sets it to be a startup camera
new_perspective_camera = pm.camera()
new_perspective_camera[0].rename("|persp")
new_perspective_camera[0].hide()
pm.camera(new_perspective_camera[0], e=True, startupCamera = True)
pm.reorder(new_perspective_camera[0], front=True)
Script Walkthrough