本文整理汇总了Python中maya.cmds.workspace方法的典型用法代码示例。如果您正苦于以下问题:Python cmds.workspace方法的具体用法?Python cmds.workspace怎么用?Python cmds.workspace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类maya.cmds
的用法示例。
在下文中一共展示了cmds.workspace方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _set_project
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import workspace [as 别名]
def _set_project():
"""Sets the maya project to the current Session's work directory.
Returns:
None
"""
workdir = api.Session["AVALON_WORKDIR"]
try:
os.makedirs(workdir)
except OSError as e:
# An already existing working directory is fine.
if e.errno == errno.EEXIST:
pass
else:
raise
cmds.workspace(workdir, openWorkspace=True)
示例2: _on_task_changed
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import workspace [as 别名]
def _on_task_changed(*args):
_update_menu_task_label()
workdir = api.Session["AVALON_WORKDIR"]
if os.path.exists(workdir):
logger.info("Updating Maya workspace for task change to %s", workdir)
_set_project()
# Set Maya fileDialog's start-dir to /scenes
frule_scene = cmds.workspace(fileRuleEntry="scene")
cmds.optionVar(stringValue=("browserLocationmayaBinaryscene",
workdir + "/" + frule_scene))
else:
logger.warning("Can't set project for new context because "
"path does not exist: %s", workdir)
示例3: check_open
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import workspace [as 别名]
def check_open():
current_project = cmds.workspace(q=True, rootDirectory=True)
scene_path = cmds.file(q=True, sceneName=True)
scene_name = cmds.file(q=True, shortName=True, sceneName=True)
msg01 = lang.Lang(
en='Workspace not found',
ja=u'ワークスペースがみつかりません')
dir_list = scene_path.split('/')
for i in range(len(dir_list)):
dir_list = dir_list[:-1]
root_dir = '/'.join(dir_list)+'/'
try:
all_files = os.listdir(root_dir)
except:
cmds.inViewMessage( amg=msg01.output(), pos='midCenterTop', fade=True, ta=0.75, a=0.5)
return
for file in all_files:
if file == 'workspace.mel':
set_work_space(root_dir)
return
cmds.inViewMessage( amg=msg01.output(), pos='midCenterTop', fade=True, ta=0.75, a=0.5)
示例4: process
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import workspace [as 别名]
def process(self, context):
import os
from maya import cmds
workspace = cmds.workspace(rootDirectory=True, query=True)
if not workspace:
# Project has not been set. Files will
# instead end up next to the working file.
workspace = cmds.workspace(dir=True, query=True)
# Maya returns forward-slashes by default
normalised = os.path.normpath(workspace)
context.set_data('workspaceDir', value=normalised)
# For backwards compatibility
context.set_data('workspace_dir', value=normalised)
示例5: launch_workfiles_app
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import workspace [as 别名]
def launch_workfiles_app(*args):
workfiles.show(
os.path.join(
cmds.workspace(query=True, rootDirectory=True),
cmds.workspace(fileRuleEntry="scene")
),
parent=self._parent
)
示例6: set_work_space
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import workspace [as 别名]
def set_work_space(root_dir):
cmds.workspace(root_dir, o=True)
current_project = cmds.workspace(q=True, rootDirectory=True)
print 'Set Current Work Space :', current_project
msg00 = lang.Lang(
en='Set Current Work Space :<hl>'+current_project+'<hl>',
ja=u'現在のプロジェクトを<hl>' +current_project+u'</hl>に設定しました')
cmds.inViewMessage( amg=msg00.output(), pos='midCenterTop', fade=True, ta=0.75, a=0.5)
#ドラッグドロップでオープンシーンする
示例7: _get_file_path
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import workspace [as 别名]
def _get_file_path(file_filter, key, file_mode):
"""Get a file path from a file dialog.
:param file_filter: File filter eg "Maya Files (*.ma *.mb)"
:param key: Optional key value to access the starting directory which is saved in
the persistent cache.
:param file_mode: 0 Any file, whether it exists or not.
1 A single existing file.
2 The name of a directory. Both directories and files are displayed in the dialog.
3 The name of a directory. Only directories are displayed in the dialog.
4 Then names of one or more existing files.
:return: The selected file path
"""
start_directory = cmds.workspace(q=True, rd=True)
if key is not None:
start_directory = get_setting(key, start_directory)
file_path = cmds.fileDialog2(
fileMode=file_mode, startingDirectory=start_directory, fileFilter=file_filter
)
if key is not None and file_path:
file_path = file_path[0]
directory = (
file_path if os.path.isdir(file_path) else os.path.dirname(file_path)
)
set_setting(key, directory)
return file_path
# MScriptUtil
示例8: get_project_rule
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import workspace [as 别名]
def get_project_rule(rule):
"""Get the full path of the rule of the project"""
workspace = cmds.workspace(query=True, rootDirectory=True)
folder = cmds.workspace(fileRuleEntry=rule)
if not folder:
log.warning("File Rule Entry '{}' has no value, please check if the "
"rule name is typed correctly".format(rule))
return os.path.join(workspace, folder)
示例9: texture_path_2_local_with_copy
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import workspace [as 别名]
def texture_path_2_local_with_copy():
all_textures = cmds.ls(type='file')
pj_path = cmds.workspace(q=1, rd=1)
tx_path = pj_path + "sourceimages/"
copy_textures = []
un_copy_texture = []
same_texture = []
msg = '- Result -'
for texture in all_textures:
texName = cmds.getAttr(texture + '.fileTextureName')
splitText = '/'
#区切り文字が\\の場合の対応
if not splitText in texName:
splitText = '\\'
tempName = texName.split(splitText)
file_name = tempName[-1]
#外部ファイルコピー
if not texName.startswith('sourceimages'):
if os.path.exists(texName):
try:
local_path = tx_path+file_name
shutil.copyfile(texName, local_path)
copy_textures.append(file_name)
except shutil.Error:
same_texture.append(file_name)
else:
un_copy_texture.append(file_name)
newName = 'sourceimages'+splitText+file_name
cmds.setAttr (texture + '.fileTextureName', newName, type = 'string')
if copy_textures:
msg += '\n*** Copy file to local directory ***'
for tex in copy_textures:
msg += '\n'+tex
if un_copy_texture:
msg += '\n*** Copy Error / Texture file not found ***'
for tex in un_copy_texture:
msg += '\n'+tex
if same_texture:
msg += '\n*** Copy Error / Texture already exist in locals ***'
for tex in same_texture:
msg += '\n'+tex
cmds.confirmDialog(m = msg)