ml_controlLibrary.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:ml_tools 作者: morganloomis 项目源码 文件源码
def exportControl(curves, name):
    '''Export a control curve
    '''

    if not isinstance(curves, (list, tuple)):
        curves = [curves]

    grp = mc.group(em=True, name=name)

    for each in curves:
        ml_parentShape.parentShape(each, grp)

    mc.delete(grp, constructionHistory=True)

    tempFile = mc.internalVar(userTmpDir=True)
    tempFile+='tempControlExport.ma'

    mc.select(grp)
    mc.file(tempFile, force=True, typ='mayaAscii', exportSelected=True)

    with open(tempFile, 'r') as f:
        contents = f.read()

    ctrlLines = ['//ML Control Curve: '+name]

    record = False
    for line in contents.splitlines():
        if line.startswith('select'):
            break
        if line.strip().startswith('rename'): #skip the uuid commands
            continue
        if line.startswith('createNode transform'):
            record = True
            ctrlLines.append('string $ml_tempCtrlName = `createNode transform -n "'+name+'_#"`;')
        elif line.startswith('createNode nurbsCurve'):
            ctrlLines.append('createNode nurbsCurve -p $ml_tempCtrlName;')
        elif record:
            ctrlLines.append(line)


    with open(controlFilePath(name), 'w') as f:
        f.write('\n'.join(ctrlLines))

    return grp
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号