我正在努力完成我的剧本,但我遇到了一些问题。 这是我的剧本:
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
值,该值表示该属性是否在您要检查的帧上有一个关键帧,但仅当它在该帧上有一个关键帧。在
例如,假设我在控件的tx属性的第1帧和第5帧有关键帧,我希望有一个字典键,稍后可以检查这些帧是否有关键帧:当该帧有关键帧时,返回true
;如果没有,则返回false
。
如果True
,我还想保存键的切线类型。在
在命令.关键帧将提供给定动画曲线的所有关键帧时间。所以很容易找到场景中的所有关键点:
或者你可以一次检查一个:
^{pr2}$您可能遇到的问题是未捕捉的关键点:如果在第30.001帧处有一个关键点,并且您询问“在30处是否有关键点”,则答案将为“否”。您可以强制使用以下整数关键点:
相关问题 更多 >
编程相关推荐