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
评论列表
文章目录