0
我正在嘗試完成我的腳本,並且遇到了一些問題。 這裏是我的腳本:瑪雅Python腳本:如果某個屬性在該特定框架處於關鍵幀時返回True或False
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
,我也想保存鍵的正切類型。