Last active
October 28, 2024 23:55
-
-
Save LiamHz/8d28284c3d936f6747ab82f5d04e90dc to your computer and use it in GitHub Desktop.
Create an ubercam for the camera sequencer, delete the previous one if it exists, set its display options, move it into the cameras group, bake camera keys, and handle "EnableSteppedPreview"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import maya.cmds as cmds | |
camera_name = 'ubercam' | |
cameras_group = 'Cameras' | |
overscan_value = 1.2 | |
gate_color = (0.0, 0.0, 0.0) | |
gate_opacity = 1.0 | |
if cmds.objExists(camera_name): | |
cmds.delete(camera_name) | |
cmds.ubercam(camera_name) | |
cmds.setAttr(f'{camera_name}.overscan', overscan_value) | |
cmds.setAttr(f'{camera_name}.displayGateMaskColor', *gate_color) | |
cmds.setAttr(f'{camera_name}.displayGateMaskOpacity', gate_opacity) | |
# Toggle the setting | |
stepped_preview = cmds.optionVar(query="animationEnableSteppedPreview") | |
# Disable stepped preview before baking camera | |
cmds.optionVar(intValue=("animationEnableSteppedPreview", 0)) | |
cmds.playbackOptions(edit=True, blockingAnim=False) | |
cmds.bakeResults(camera_name, t=(0,None), sampleBy=1) | |
# Re-enable stepped preview if it was enabled before | |
if stepped_preview: | |
cmds.optionVar(intValue=("animationEnableSteppedPreview", 1)) | |
cmds.playbackOptions(edit=True, blockingAnim=True) | |
cmds.parent(camera_name, cameras_group) | |
cmds.select(camera_name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment