import maya.cmds as cmds
import math
# Get the name of the current camera
current_camera = cmds.modelPanel(cmds.getPanel(withFocus=True), q=True, camera=True)
# Set the film aspect ratio of the current camera to 1.78
cmds.setAttr(current_camera + '.cameraAperture', 1.78, type='double2')
# Set the camera aperture to correspond to a 1.78 aspect ratio
diagonal = math.sqrt((36**2) + (20.25**2))
horizontal = diagonal / math.sqrt((1.78**2) + 1)
vertical = horizontal / 1.78
cmds.setAttr(current_camera + '.horizontalFilmAperture', horizontal)
cmds.setAttr(current_camera + '.verticalFilmAperture', vertical)
More than 1 year has passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme