LoginSignup
0
0

More than 1 year has passed since last update.

python maya change camera asceptRatio

Posted at
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)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0