pymel.core.system.Workspace

Inheritance diagram of Workspace

class Workspace(*p, **k)

This class is designed to lend more readability to the often confusing workspace command. The four types of workspace entries (objectType, fileRule, renderType, and variable) each have a corresponding dictiony for setting and accessing these mappings.

>>> from pymel.all import *
>>> workspace.fileRules['mayaAscii']
u'scenes'
>>> workspace.fileRules.keys() 
[...u'mayaAscii', u'mayaBinary',...]
>>> 'mayaBinary' in workspace.fileRules
True
>>> workspace.fileRules['super'] = 'data'
>>> workspace.fileRules.get( 'foo', 'some_default' )
'some_default'

the workspace dir can be confusing because it works by maintaining a current working directory that is persistent between calls to the command. In other words, it works much like the unix ‘cd’ command, or python’s ‘os.chdir’. In order to clarify this distinction, the names of these flags have been changed in their class method counterparts to resemble similar commands from the os module.

old way (still exists for backward compatibility)
>>> proj = workspace(query=1, dir=1)
>>> proj  
u'...'
>>> workspace(create='mydir')
>>> workspace(dir='mydir') # move into new dir
>>> workspace(dir=proj) # change back to original dir
new way
>>> proj = workspace.getcwd()
>>> proj  
Path('...')
>>> workspace.mkdir('mydir')
>>> workspace.chdir('mydir')
>>> workspace.chdir(proj)
All paths are returned as an pymel.core.system.Path class, which makes it easy to alter or join them on the fly.
>>> workspace.path / workspace.fileRules['mayaAscii']  
Path('...')
classmethod chdir(newdir)
fileRules = WorkspaceEntryDict('fileRule')
classmethod getName()
classmethod getPath()
classmethod getcwd()
classmethod mkdir(newdir)
name
classmethod new(workspace)
objectTypes = WorkspaceEntryDict('objectType')
classmethod open(workspace)
path
renderTypes = WorkspaceEntryDict('renderType')
classmethod save()
classmethod update()
variables = WorkspaceEntryDict('variable')

Previous topic

pymel.core.system.Translator

Next topic

pymel.core.system.WorkspaceEntryDict

Core

Core Modules

Other Modules

This Page