我正在尝试完成我的脚本,但遇到了一些问题。这是我的脚本:
from maya import cmds
def correct_value(selection=None, prefix='', suffix=''):
newSel = []
if selection is None:
selection = cmds.ls ('*_control')
if selection and not isinstance(selection, list):
newSel = [selection]
for each_obj in selection:
if each_obj.startswith(prefix) and each_obj.endswith(suffix) :
newSel.append(each_obj)
return newSel
def save_pose(selection):
pose_dictionary = {}
for each_obj in selection:
pose_dictionary[each_obj] = {}
for each_attribute in cmds.listAttr (each_obj, k=True):
pose_dictionary[each_obj][each_attribute] = cmds.getAttr (each_obj + "." + each_attribute)
return pose_dictionary
controller = correct_value(None,'left' ,'control' )
save_pose(controller)
def save_animation(selection, **keywords ):
if "framesWithKeys" not in keywords:
keywords["framesWithKeys"] = [0,1,2,3]
animation_dictionary = {}
for each_frame in keywords["framesWithKeys"]:
cmds.currentTime(each_frame)
animation_dictionary[each_frame] = save_pose(selection)
return animation_dictionary
frames = save_animation (save_pose(controller) )
print frames
现在,当我查询一个属性时,我想在字典中存储一个True
或False
值,说明该属性是否在您正在检查的那个帧上有一个关键帧,但前提是它在那个帧上有一个关键帧。
例如,假设我在第 1 帧和第 5 帧的控件的 tx 属性上有键,我想要一个字典键,我可以稍后检查这些帧是否有键:当该帧有键时, 返回true
; 没有时,返回false
。如果True
,我还想保存键的切线类型。