lib.py 文件源码

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

项目:maya-capture-gui 作者: Colorbleed 项目源码 文件源码
def browse(path=None):
    """Open a pop-up browser for the user"""

    # Acquire path from user input if none defined
    if path is None:

        scene_path = cmds.file(query=True, sceneName=True)

        # use scene file name as default name
        default_filename = os.path.splitext(os.path.basename(scene_path))[0]
        if not default_filename:
            # Scene wasn't saved yet so found no valid name for playblast.
            default_filename = "playblast"

        # Default to images rule
        default_root = os.path.normpath(get_project_rule("images"))
        default_path = os.path.join(default_root, default_filename)
        path = cmds.fileDialog2(fileMode=0,
                                dialogStyle=2,
                                startingDirectory=default_path)

    if not path:
        return

    if isinstance(path, (tuple, list)):
        path = path[0]

    if path.endswith(".*"):
        path = path[:-2]

    # Bug-Fix/Workaround:
    # Fix for playblasts that result in nesting of the
    # extension (eg. '.mov.mov.mov') which happens if the format
    # is defined in the filename used for saving.
    extension = os.path.splitext(path)[-1]
    if extension:
        path = path[:-len(extension)]

    return path
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号