1

キーフレームをあるリグから別のリグにコピーする Maya 用の Python スクリプトを作成しようとしています。オブジェクトを見つけて一致させました。私が今やろうとしているのは、元のオブジェクトにコピーするキーがある場合、元のオブジェクトからキーをコピーすることです。Keyframe コマンドを使用して、オブジェクトにキーがあるかどうかを確認したいと考えていました。

例: cmds.keyframe(oldObjPath attribute=oldAttr,sl=True, q=True, tc=True ) > 0 の場合:

ただし、これは常に false を返しました。oldObjPath の属性を出力すると、すべての属性が出力されます。私がここで間違っていることは何か分かりますか? 完全なコードは以下にあります

キーフレーム コマンドに関するドキュメント: http://download.autodesk.com/global/docs/maya2014/en_us/index.html?url=files/Python_Python_in_Maya.htm,topicNumber=d30e813275

#create a decunary of the object names and paths for faster searching
#[search_name:path]

originalObjectDic = {}
newObjectDic = {}

for obj in originalObjects:

    #First remove the full path to give us somthing to search the new object with
    subStrLoc = 0
    index = 0
    for char in obj:
        if char == ':':
            subStrLoc = index
        index=index+1

    searchName = obj[subStrLoc+1:]

    originalObjectDic.update({searchName:obj})


    #next look at all the names of the new object and see if they match up    
for nObj in newObjects:
    #correct the new objects name
    subStrLoc=0
    index=0
    for char in nObj:
        if index != 0:
            if char == '_' and nObj[index-1] == 'r' and nObj[index-2] == 'u' and nObj[index-3] == 'F':
                    subStrLoc = index
        index = index + 1  

    if subStrLoc == 0:
        index = 0
        for char in obj:
            if char == ':':
                subStrLoc = index
        index=index+1 

    searchName = nObj[subStrLoc+1:]
    newObjectDic.update({searchName:nObj})   


#now that we have to dicunaries to check agaenst we will match up the two obj paths
# and copy the keys on all attributes on each node

for key in newObjectDic:

    newObjPath = newObjectDic.get(key)
    oldObjPath = originalObjectDic.get(key)
    #if there is a match between the two dics
    if newObjPath != None and oldObjPath != None:
        #get a list of all the attributes
        newObjAttributes = cmds.listAttr(newObjPath,v=True,r=True, w=True)
        oldObjAttributes = cmds.listAttr(oldObjPath,v=True,r=True, w=True)

        for x in range(len(newObjAttributes)-1):
            newAttr = newObjAttributes[x]
            oldAttr = oldObjAttributes[x]
            if cmds.keyframe(oldObjPath attribute=oldAttr,sl=True, q=True, tc=True ) > 0:
                print oldObjPath
                print oldAttr
                print 'Has Key'
                print '----------------------------'
4

1 に答える 1

3

友人に助けてもらいました。間違ったオプションをオンにしました。選択を表す sl は false であるか、まったく存在しないはずです...

if cmds.keyframe(oldObjPath, attribute=oldAttr, sl=False, q=True, tc=True):
于 2015-04-30T19:48:23.543 に答える