# coding=Utf-8
# aut:zy
import re
import pymel.core as pm
def get_keyframe(obj):
"""
递归查找父物体或者父物体关联的节点上是否有关键帧
如果有关键帧且有变化,则该物体需要出缓存
如果没有关键帧或者有关键帧但无变化,则该物体不需要出缓存
Args:
obj:
Returns: bool
"""
KEY_ANICURVE = ['animCurveTL', 'animCurveTA', 'animCurveTT', 'animCurveTU']
connect_s = obj.listConnections(s=1, d=0, scn=1)
if not connect_s:
return False
else:
result = 0
for connect in connect_s:
if connect.nodeType() == 'transform':
objs = obj.listConnections(s=1, d=0, p=1, scn=1)
if not objs:
return False
for obj in objs:
result += get_keyframe(obj)
elif connect.nodeType() in KEY_ANICURVE:
attr = connect.listConnections(s=0, d=1, p=1, scn=1)[0]
if len(set(pm.keyframe(attr, q=1, vc=1))) > 1:
return True
else:
return False
else:
objs = obj.listConnections(s=1, d=0, scn=1)
if not objs:
return False
for obj in objs:
result += get_keyframe(obj)
return bool(result)
上一篇
获取指定mesh的material
2024-05-10
下一篇
获取摄像机filegate属性
2024-05-10