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)
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