Python maya.cmds.workspace() Examples
The following are 9
code examples of maya.cmds.workspace().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
maya.cmds
, or try the search function
.
Example #1
Source File: pipeline.py From core with MIT License | 7 votes |
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)
Example #2
Source File: pipeline.py From core with MIT License | 6 votes |
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)
Example #3
Source File: setup.py From SISideBar with MIT License | 6 votes |
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)
Example #4
Source File: collect_workspace.py From pyblish-maya with GNU Lesser General Public License v3.0 | 6 votes |
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)
Example #5
Source File: pipeline.py From core with MIT License | 5 votes |
def launch_workfiles_app(*args): workfiles.show( os.path.join( cmds.workspace(query=True, rootDirectory=True), cmds.workspace(fileRuleEntry="scene") ), parent=self._parent )
Example #6
Source File: setup.py From SISideBar with MIT License | 5 votes |
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) #ドラッグドロップでオープンシーンする
Example #7
Source File: shortcuts.py From cmt with MIT License | 5 votes |
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
Example #8
Source File: lib.py From maya-capture-gui with MIT License | 5 votes |
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)
Example #9
Source File: texture.py From SISideBar with MIT License | 4 votes |
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)