首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Maya :检查该属性是否有任何关键帧

Maya :检查该属性是否有任何关键帧
EN

Stack Overflow用户
提问于 2015-04-30 19:14:45
回答 1查看 4.3K关注 0票数 1

我正试图为玛雅编写一个python脚本,它将把关键帧从一个平台复制到另一个平台。我找到了一些东西,并把它们匹配起来。我现在要做的是,如果原始对象有要复制的键,则从原始对象复制密钥。我希望使用Keyframe命令来检查对象是否有键。

示例: if cmds.keyframe(oldObjPath attribute=oldAttr,sl=True,q=True,tc=True )> 0:

然而,这始终是假的。当我打印出oldObjPath的属性时,我确实会打印出所有的属性。你知道我在这里做错什么了吗?完整代码如下

关于关键帧命令的文档:Maya.htm,topicNumber=d30e813275

代码语言:javascript
复制
#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 '----------------------------'
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-04-30 19:48:23

从一个怪物那里得到了帮助。有错误的选择。表示选择的sl应该是假的,或者根本不存在.

代码语言:javascript
复制
if cmds.keyframe(oldObjPath, attribute=oldAttr, sl=False, q=True, tc=True):
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29975922

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档