def GetAllByType(selType="joint"):
all_curves = cmds.ls(type=selType, ni=True, o=True, r=True, l = True)
curves_transforms = cmds.listRelatives(all_curves, p=True, type = "transform")
return curves_transforms
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 []) # Get all the keys and sort them by order. We use `or []` in-case it has no keys, which will use an empty list instead so it doesn't crash `sort`.
if all_keys: # Check to see if it at least has one key.
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)
min, max = GetMinMaxFrame()
print(min, max)
More than 1 year has passed since last update.
python maya get min max key frame
Last updated at Posted at 2023-06-30
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