maya_tools.py 文件源码

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

项目:gozbruh 作者: LumaPictures 项目源码 文件源码
def export(objs):
    """Save files.

    Checks for gozbruhParent attr.

    gozbruhParent is used to import objects in correct order in ZBrush
    gozbruhParent determines the top level tool in ZBrush

    If no instance exists, it is created

    Returns
    -------
    list of (str, str)
        list of object, parent pairs
    """
    parents = []

    for obj in objs:
        # export each file individually
        cmds.select(cl=True)
        cmds.select(obj)
        cmds.delete(ch=True)
        ascii_path = utils.make_maya_filepath(obj)
        cmds.file(ascii_path,
                  force=True,
                  options="v=0",
                  type="mayaAscii",
                  exportSelected=True)
        if cmds.attributeQuery('gozbruhParent', node=obj, exists=True):
            # object existed in zbrush, has 'parent' tool
            parent = cmds.getAttr(obj + '.gozbruhParent')
            # append to the end of parents
            parents.append((obj, parent))
        else:
            cmds.addAttr(obj, longName='gozbruhParent', dataType='string')
            cmds.setAttr(obj + '.gozbruhParent', obj, type='string')
            # prepend to the beginning of parents, we want these objects
            # imported first
            parents = [(obj, obj)] + parents

        # maya is often run as root, this makes sure osx can open/save
        # files not needed if maya is run un-privileged
        os.chmod(ascii_path, 0o777)
    return parents
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号