Go to: Synopsis. Return value. Related. Flags. Python examples.

Synopsis

workspace( [string] , [active=boolean], [baseWorkspace=string], [create=string], [directory=string], [expandName=string], [fileRule=[string, string]], [fileRuleEntry=string], [fileRuleList=boolean], [fullName=boolean], [list=boolean], [listFullWorkspaces=boolean], [listWorkspaces=boolean], [newWorkspace=boolean], [objectType=[string, string]], [objectTypeEntry=string], [objectTypeList=boolean], [openWorkspace=boolean], [projectPath=string], [renderType=[string, string]], [renderTypeEntry=string], [renderTypeList=boolean], [rootDirectory=string], [saveWorkspace=boolean], [shortName=boolean], [update=boolean], [updateAll=boolean], [variable=[string, string]], [variableEntry=string], [variableList=boolean])

Note: Strings representing object names and arguments must be separated by commas. This is not depicted in the synopsis.

workspace is undoable, queryable, and NOT editable.

Create, open, or edit a workspace associated with a given workspace file.

The string argument reprents the workspace. If no workspace is specified then the current workspace is assumed.

Return value

string
string[]

In query mode, return type is based on queried flag.

Related

translator

Flags

active, baseWorkspace, create, directory, expandName, fileRule, fileRuleEntry, fileRuleList, fullName, list, listFullWorkspaces, listWorkspaces, newWorkspace, objectType, objectTypeEntry, objectTypeList, openWorkspace, projectPath, renderType, renderTypeEntry, renderTypeList, rootDirectory, saveWorkspace, shortName, update, updateAll, variable, variableEntry, variableList
Long name (short name) Argument types Properties
newWorkspace(n) boolean create
This specifies that a new workspace is being created. If a workspace with this name already exists, the command will fail.
openWorkspace(o) boolean createquery
Open the workspace. The workspace becomes the current workspace.
active(act) boolean createquery
This flag is a synonym for -o/openWorkspace.
saveWorkspace(s) boolean create
Save the workspace. Workspaces are normally saved when Maya exits but this flag will make sure that the data is flushed to disk.
baseWorkspace(bw) string query
A workspace may be based on another workspace. This means that all the settings in the base workspace apply to this workspace unless they are explicitly overridden.
listWorkspaces(lw) boolean createquery
Returns a list of all the currently defined workspace names.
listFullWorkspaces(lfw) boolean createquery
Returns a list of the full path names of all the currently defined workspaces.
list(l) boolean createquery
This option will list the current workspace directory. If a path is specified for the "workspaceFile" then the contents of that directory will be listed. Otherwise, the contents of the directory set with the -dir flag will be listed.
directory(dir) string createquery
This option will set the current workspace directory to the path specified. When queried it will return the current workspace directory. This directory is used as an initial directory for the fileBrowser and is part of the search path used for locating files. It should not be confused with the current working directory as used by the pwd and chdir commands.
create(cr) string create
Create a new directory. If the directory name is not a full path name, it will be created as a subdirectory of the "current" directory set with the -dir flag.
rootDirectory(rd) string createquery
Returns the root directory of the workspace.
objectType(ot) [string, string] createquery
This flag is obsolete. All default locations will be added to the fileRules going forward.
objectTypeList(otl) boolean createquery
This flag is obsolete. This will now return the same results as fileRuleList going forward.
objectTypeEntry(ote) string createquery
This flag is obsolete. This will now return the same as fileRuleEntry.
fileRule(fr) [string, string] createquery
Set the default location for a file. The first parameter is the fileRule (dxf, iges, etc) and the second is the location. When queried, it returns a list of strings. The elements of the list alternate between fileRule names and the corresponding location. There is typically one file rule for each available translator. Environment variables are supported. Maya will add the following defaults: scene, image, depth, iprImages, lights, renderScenes, sourceImages and textures.
fileRuleList(frl) boolean createquery
Returns a list of the currently defined file rules.
fileRuleEntry(fre) string createquery
Return the location for the given fileRule.
renderType(rt) [string, string] createquery
This flag is obsolete. All default render types will be added to fileRules going forward.
renderTypeList(rtl) boolean createquery
This flag is obsolete, use fileRuleList going forward.
renderTypeEntry(rte) string createquery
This flag is obsolete, use fileRuleEntry going forward
variable(v) [string, string] createquery
Set/query the value of a project variable. Project variables are used when expanding names. See the -en/expandName flag below.
variableList(vl) boolean createquery
Return a list of all the available variables.
variableEntry(ve) string createquery
Return the value of the given variable name
shortName(sn) boolean createquery
Query the short name of the workspace.
fullName(fn) boolean createquery
Return the full name of the workspace.
expandName(en) string createquery
Query for the full path location of a the filename name. The name may be a project relative file name, or a full path name. If the name is an empty string, the return value will be the project directory. The return value is always a full path name.
projectPath(pp) string createquery
Convert filePath passed as argument to a filename that is relative to the project root directory (if possible) and return it. If the filePath is not under the project root directory, a full path name will be returned.
update(u) boolean create
This flag reads all the workspace definitions from the project directory. It is used by Maya at startup time to find the avaiable workspaces.
updateAll(ua) boolean create
This flag is a synonym for -u/update.

Flag can appear in Create mode of command Flag can appear in Edit mode of command
Flag can appear in Query mode of command Flag can have multiple arguments, passed either as a tuple or a list.

Python examples

import maya.cmds as cmds

# Set the current workspace to "alphabet".
cmds.workspace( 'alphabet', o=True )

# Save the currently workspace settings (for "alphabet").
cmds.workspace( s=True )

# Create a new Workspace named "newWorkspace".
cmds.workspace( 'newWorkspace', n=True )

# Find the current workspace area.
cmds.workspace( q=True, dir=True )
# Result : /h/userName/maya/projects/default

# Note that the "current working directory" as defined by the
# 'pwd' and 'chdir' commands is unrelated to the directories
# used by the workspace command.
#
cmds.pwd()
# Result : /usr/tmp

cmds.chdir( '/tmp' )
getcwd()
# Result : /tmp
cmds.workspace( q=True, dir=True )
# Result : /h/userName/maya/projects/default

cmds.workspace( dir='/h/userName/maya/projects/commercial' )
getcwd()
# Result : /tmp