ジャンプ先: 概要. 戻り値. 関連項目. フラグ. Python 例.

概要

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

注意: オブジェクト名や引数を表す文字列はカンマで区切ります。これは概要には示されていません。

workspace は 「元に戻す」が可能、「照会」が可能、「編集」が不可能 です。

指定したワークスペース ファイルに従って、ワークスペースを生成したり、 開いたり、編集したりします。この文字列引数はワークスペースを表します。ワークスペースが指定されていない場合、現在のワークスペースが指定されたものとみなされます。ワークスペースは Maya プロジェクトの基本となる定義を提供します。各プロジェクトには workspace.mel という関連付けされたワークスペース ファイルがあり、プロジェクトのルート ディレクトリに保存されています。 ワークスペース ファイルは、ファイル タイプをルート ディレクトリに対して相対的または絶対的な保存場所にマップする一連の規則を定義します。この規則は、実行時にファイル パスを解決する際に使用されます。ワークスペース コマンドは、定義の基本ファイルへの読出し、変更、保存時には、ワークスペースの低レベルの定義で直接動作します。このコマンドを使用する必要はほとんどありません。通常は、プロジェクト定義の変更はユーザ インタフェースのプロジェクト ウィンドウを介して行うことをお勧めします。

戻り値

string
string[]

戻り値の型は照会モードでは照会フラグが基になります。

関連項目

translator

フラグ

active, baseWorkspace, create, directory, expandName, fileRule, fileRuleEntry, fileRuleList, filter, fullName, list, listFullWorkspaces, listWorkspaces, newWorkspace, objectType, objectTypeEntry, objectTypeList, openWorkspace, projectPath, removeFileRuleEntry, removeVariableEntry, renderType, renderTypeEntry, renderTypeList, rootDirectory, saveWorkspace, shortName, update, updateAll, variable, variableEntry, variableList
ロング ネーム(ショート ネーム) 引数型 プロパティ
newWorkspace(n) boolean create
新しいワークスペースの作成を指定します。同じ名前のワークスペースがすでに存在する場合、 コマンドは失敗します。
openWorkspace(o) boolean createquery
ワークスペースを開きます。開かれたワークスペースがカレントの ワークスペースになります。
active(act) boolean createquery
このフラグは -o/openWorkspace フラグと同義です。
saveWorkspace(s) boolean create
ワークスペースを保存します。通常、ワークスペースは Maya が終了するときに保存されますが、 このフラグを使用するとデータは確実にディスクに保存されます。
baseWorkspace(bw) string query
ワークスペースは別のワークスペースをベースにしている場合があります。したがって、はっきり優先の指定がない場合、ベースのワークスペースの全設定が このワークスペースに適用されます。
listWorkspaces(lw) boolean createquery
現在設定されているワークスペースの名前の リストを返します。
listFullWorkspaces(lfw) boolean createquery
現在設定されている、すべてのワークスペースの名前の フル パスのリストを返します。
list(l) boolean createquery
このオプションは、カレント ワークスペース ディレクトリをリストします。「workspaceFile」用にパスが指定されている場合、 このディレクトリのコンテンツがリストされます。指定されていなければ、-dir フラグで設定された ディレクトリの内容がリストされます。
directory(dir) string createquery
このオプションは、カレントのワークスペース ディレクトリを 指定したパスに設定します。照会すると、カレントのワークスペース ディレクトリを返します。このディレクトリは、fileBrowser の 最初のディレクトリとして使用され、ファイルの位置を指定する 検索パスの一部となります。pwd および chdir コマンドが使用する カレント ワーキング ディレクトリと混同しないでください。 ファイル ブラウザを使用する場合、この値は最後に参照した場所に設定されます。
create(cr) string create
新しいディレクトリを作成します。ディレクトリの名前がフル パスでなかった場合、 このディレクトリは、-dir フラグで設定されたカレント ディレクトリの サブディレクトリとして作成されます。
rootDirectory(rd) boolean query
ワークスペースのルート ディレクトリを返します。
objectType(ot) [string, string] createquery
このフラグは現在サポートしていません。 今後、デフォルト位置はすべて fileRules に追加されます。
objectTypeList(otl) boolean createquery
このフラグは現在サポートしていません。 今後、これは fileRuleList と同じ結果を返します。
objectTypeEntry(ote) string createquery
このフラグは現在サポートしていません。 これは、fileRuleEntry と同じ結果を返します。
fileRule(fr) [string, string] createquery
ファイルのデフォルト位置を設定します。1 番目のパラメータは fileRule(シーン、イメージなど)で、2 番目は位置です。照会すると文字列のリストを返します。リストには、fileRule 名とその場所が交互に現れます。通常、使用可能なトランスレータ 1 つにつき、 1 つのファイル規則があります。 環境変数がサポートされています。ファイル規則用に複数のパスを設定する場合、Windows ではセミコロン(;)、MacOSX と Linux ではコロン(:)で区切ります。パスごとに冒頭と末尾にスペースを入れることが重要です。スペースはパス名の一部として扱われます(実際にスペースで始まったりスペースで終わるわけではありません)。
fileRuleList(frl) boolean createquery
現在定義されている fileRule のリストを返します。
fileRuleEntry(fre) string createquery
指定した fileRule の位置を返します。
removeFileRuleEntry(rfr) string create
指定したワークスペースから指定したファイル規則を削除します。 ワークスペース名が指定されていない場合、カレント ワークスペースから指定したファイル規則が削除されます。
renderType(rt) [string, string] createquery
このフラグは現在サポートしていません。 デフォルト レンダー タイプは今後すべて fileRules に追加されます。
renderTypeList(rtl) boolean createquery
このフラグはサポートしていません。今後は fileRuleList を使用してください。
renderTypeEntry(rte) string createquery
このフラグはサポートしていません。今後は fileRuleEntry を使用してください。
variable(v) [string, string] createquery
プロジェクト変数を設定または照会します。プロジェクト変数は、名前の展開時に使用されます。次の -en/expandName を参照してください。
variableList(vl) boolean createquery
ワークスペースのすべての変数のリストを返します。
variableEntry(ve) string createquery
変数名を指定すると、その値が返されます。
removeVariableEntry(rve) string create
指定したワークスペースから指定した変数を削除します。 ワークスペース名が指定されていない場合、カレント ワークスペースから指定した変数が削除されます。
shortName(sn) boolean createquery
ワークスペースのショート ネームを照会します。
fullName(fn) boolean createquery
ワークスペースのフル ネームを返します。
expandName(en) string createquery
カレントのワークスペース定義を使用してファイル名のフル パスの場所を照会します。パスはプロジェクトの相対的なファイル名、フル パス名、または変数名になります。戻り値は必ずフル パス名となります。 パスが空の文字列の場合、戻り値はプロジェクトのルート ディレクトリになります。変数の拡張子をサポートしているため、ワークスペースで定義された変数と環境変数の両方が考慮されます。 拡張変数名には次の 3 つのフォーマットがサポートされています: %variableName%、$variableName、${variableName}。 まず、カレントのワークスペースで定義された変数が検索され、次に環境変数が検索されます。 チルダ(~)もサポートしています。変数の冒頭にチルダを入れると、Maya では、環境変数のみを考慮して展開し、展開結果にチルダを残します。Linux でのみ、チルダを使用して ~username、~、または ~/ のフォームでユーザのホーム ディレクトリを展開できます。~username と指定すると該当するユーザのホーム ディレクトリに置き換えられ、~ または ~/ と指定すると HOME 環境変数の値に置き換えられます。
projectPath(pp) string createquery
引数として渡された filePath を、(可能な場合は)プロジェクト ルート ディレクトリを基準にした ファイル名に変換して返します。ファイルパスがプロジェクトのルート ディレクトリの下にない場合、 フル パス名を返します。
update(u) boolean create
このフラグはプロジェクト ディレクトリから、 すべてのワークスペース設定を読み込みます。Maya ではスタートアップ時に使用し、使用可能なワークスペースを検索します。
updateAll(ua) boolean create
このフラグは -u/update と同義です。
filter(f) boolean
このフラグは現在サポートしていません。

: コマンドの作成モードで使用可能なフラグ : コマンドの編集モードで使用可能なフラグ
: コマンドの照会モードで使用可能なフラグ : タプルまたはリストとして渡された複数の引数を持てるフラグ

Python 例

import maya.cmds as cmds

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

# Save the current workspace settings (for "alphabet").
cmds.workspace( saveWorkspace=True )

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

# The settings of "newWorkspace" are based on "default" workspace
cmds.workspace( baseWorkspace='default' )

# Return the list of existing workspaces
cmds.workspace( listWorkspaces=True )
# Result: default   newWorkspace

# Add a scriptJob to run on workspaceChanged events
def workspaceChangedCallback():
    print 'My workspaceChangedCallback was called'

workspaceChangedID = cmds.scriptJob( event = ["workspaceChanged", workspaceChangedCallback] )

# add a file rule to the current workspace
cmds.workspace(fileRule = ['newFileRuleName', 'newFileRuleValue'])
My workspaceChangedCallback was called            #workspaceChangedCallback was called

# look up the value of the file rule entry
cmds.workspace(q = True, fileRuleEntry = 'newFileRuleName')
# Result: newFileRuleValue

# remove specified file rule entry
cmds.workspace(removeFileRuleEntry = 'newFileRuleName')
My workspaceChangedCallback was called            #workspaceChangedCallback is called

# kill the scriptJob with the number
cmds.scriptJob(kill = workspaceChangedID)

# The following example shows how to expand environment and workspace variables

# expand a path value to be a full path relative to the project directory
# relative path example
cmds.workspace( expandName = 'relativePathName')
# Result: /h/userName/maya/projects/newWorkspace/relativePathName/
# full path example
cmds.workspace( expandName = '/h/userName/maya/projects/default/')
# Result: /h/userName/maya/projects/default/

# The following examples show various formats for expanding workspace and
# environment variables.

# add a variable to the current workspace
cmds.workspace(variable = ['newVariableName', 'newVariableValue'])
cmds.workspace( expandName = '%newVariableName%')
# Result: /h/userName/maya/projects/newWorkspace/newVariableValue/

# add an environment variable with the same as the workspace variable
maya.mel.eval('putenv "newEnvVariableName" "newEnvVariableValue"')
cmds.workspace( expandName = '%newEnvVariableName%')
# Result: /h/userName/maya/projects/newWorkspace/newEnvVariableValue/

# The following example shows how conflicting names in both workspace
# and environment variables are resolved.
# add a environment variable with the same name as a workspace variable
maya.mel.eval('putenv "newVariableName" "newEnvVariableValue"')
# maya considers workspace variables first before matching environment variables
cmds.workspace( expandName = '%newVariableName%')
# Result: /h/userName/maya/projects/newWorkspace/newVariableValue/

# When a tilde is used, maya will only consider the environment variable
# not the workspace variable.
cmds.workspace( expandName = '~%newVariableName%')
# Result: /h/userName/maya/projects/newWorkspace/~newEnvVariableValue/

# The following example shows how to set multiple paths into a fileRule value
cmds.workspace(fileRule = ['newMultiPathFileRuleName', '/h/userName/maya/projects/default;newFileRuleValue'])
multipath = cmds.workspace(q = True, fileRuleEntry = 'newMultiPathFileRuleName')
# Result : /h/userName/maya/projects/default;newFileRuleValue

# The following will only return the first expanded path.
cmds.workspace( expandName = multipath)
# Result : /h/userName/maya/projects/default

# Note that white space at the beginning or end of each path is significant.
# Add a file rule that uses multiple paths with the white space at the beginning and end of each path
cmds.workspace(fileRule = ['newMultiPathFileRuleName', ' /h/userName/maya/projects/default ; newFileRuleValue '])
# Querying and expanding the path value shows that the white space is still included.
multipath = cmds.workspace(q = True, fileRuleEntry = 'newMultiPathFileRuleName')
# Result :  /h/userName/maya/projects/default ; newFileRuleValue

# Find the current workspace area.
cmds.workspace( q=True, directory=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, directory=True )
# Result : /h/userName/maya/projects/default

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