LoginSignup
0
0

More than 1 year has passed since last update.

maya python get all keyframe

Last updated at Posted at 2023-02-23
def GetMinMaxFrame(selType="joint"):
    import math
    joints = GetAllByType(selType)
    minKey = 10000
    maxKey = 0
    for joint in joints:
        all_keys = sorted(cmds.keyframe(joint, q=True) or [])
        if all_keys:
            if all_keys[0] < minKey: minKey = all_keys[0]
            if all_keys[-1] > maxKey: maxKey = all_keys[-1]
    return math.floor(minKey), math.ceil(maxKey)

def set_playback_range_to_fit_keyframes():
    start_frame, end_frame = GetMinMaxFrame()
    pm.playbackOptions(minTime=start_frame)
    pm.playbackOptions(maxTime=end_frame)
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