移動先: 概要 戻り値 関連項目 フラグ MEL の例

概要

namespace [-addNamespace string] [-exists string] [-force] [-moveNamespace string string] [-parent string] [-removeNamespace string] [-setNamespace string] [string]

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

このコマンドを使用して、ネームスペースの作成、設定、または削除が可能です。

ネームスペースとは、特定の名前で複数のオブジェクトを単にグループ化したものです。 ネームスペースは、主に Maya での名前の衝突を回避するために使用されます。名前の衝突とは、ファイルをインポートした場合などに、新規のオブジェクトが既存のオブジェクトと同じ名前を持つことを指します。 ネームスペースを使用すると、2 つのオブジェクトが別のネームスペースにあれば、同じ名前を付けることができます。

ネームスペースは、ファイル システムのような階層状の構造になっていると考えてください。ネームスペースはディレクトリにあたり、オブジェクトはファイルにあたります。ネームスペース名を区切るには、コロン(':')記号を使用します。スラッシュ('/')や円記号('\')は使用しません。 ネームスペースは、オブジェクトだけでなく、他のネームスペースを含むことができます。 オブジェクト同様、1つのネームスペース内い含めるネームスペース名はそれぞれ固有でなければなりません。オブジェクトおよびネームスペースは、1つのネームスペースにしか存在できません。ネームスペース名とオブジェクト名は衝突しないため、1つのネームスペース内であっても、ネームスペースとオブジェクトは同じ名前にすることができます。

コロン(':')に続けて、名称が未設定のルート ネームスペースが指定されています。 名前のついたネームスペースにない他のすべてのオブジェクトは、ルート ネームスペースにあります。 オブジェクト名の前のコロンはなくてもわかるため、通常は省略されています。 最初のコロンが重要になるのは、「rename」コマンドを使用して、ネームスペース間でオブジェクトを移動する場合です。「rename」コマンドでは、新規の名前はカレント ネームスペースに関連します。ただし、最初のコロンを使用した完全な名前の場合にはこの限りではありません。

ネームスペースの作成には add/addNamespace フラグが使用されます。カレント ネームスペースに作成されます。カレント ネームスペースの変更は、-set/setNamespace フラグで行います。カレント ネームスペースを ルート ネームスペースにリセットするには、「namespace -set ":";」を使用します。オブジェクトが 作成されると、必ずカレント ネームスペースに追加されます。

戻り値

string

関連項目

namespaceInfo

フラグ

addNamespace, exists, force, moveNamespace, parent, removeNamespace, setNamespace
ロング ネーム(ショート ネーム) 引数型 プロパティ
-addNamespace(-add) string create
指定した名前のネームスペースを作成します。
-exists(-ex) string create
指定したネームスペースがある場合は true、ない場合は false を返します。
-force(-f) create
名前の衝突を無視する移動操作を強制的に実行するために -mv/-moveNamespace と併用します。
-moveNamespace(-mv) string string create
1 番目のネームスペースの内容を 2 番目のネームスペースに移動します。 子ネームスペースも移動されます。

参照されたノードノードを含むネームスペースを移動しようとすると、エラーが発生します。「file -e -namespace」コマンドを使用して、リファレンス ネームスペースを変更してください。

移動元のネームスペースに移動先のネームスペース内のオブジェクトと同じ名前のオブジェクトが含まれる場合、エラーが発生します。「-force」フラグを使用してこのエラーを無効にしてください。オブジェクトの名前を変更して固有な名前にすると、名前の衝突を解決できます。
-parent(-p) string create
-add/-addNamespace と併用して、新規のネームスペースの親を指定します。
-removeNamespace(-rm) string create
指定したネームスペースを削除します。削除するためには、そのネームスペースは空でなければなりません。
-setNamespace(-set) string create
カレント ネームスペースを設定します。

: コマンドの作成モードで使用可能なフラグ : コマンドの編集モードで使用可能なフラグ
: コマンドの照会モードで使用可能なフラグ : 1 つのコマンドで複数回使用可能なフラグ

MEL の例

  // Create three namespaces
namespace -add "FOO";
namespace -add "BAR";
namespace -add "FRED";

  // Set the current namespace to FOO
namespace -set "FOO";

  // Create the namespace BAR Under FOO. Note there are
  // two "BAR" namespaces, :BAR and :FOO:BAR.
namespace -add "BAR";

  // Check to see that the BAR namespace exists within the current
  // namespace (FOO)
  namespace -exists "BAR";
  // Result: 1 //

  // Check to see that the FRED namespace exists under the root namespace
  namespace -exists ":FRED";
  // Result: 1 //

  // Create two objects. It gets added to the current namespace FOO;
  sphere -n sphere1;
  sphere -n sphere2;
  // Result: FOO:sphere2 //

  // Move sphere1 from namespace FOO to FOO:BAR. Note that we
  // need to qualify sphere1 with the namespace FOO because
  // "sphere1" identifies a non-existent object in the root namespace.
  rename FOO:sphere1 "BAR:sphere1";
  // Result: FOO:BAR:sphere1 //

  // Move sphere2 from namespace FOO to BAR.  Note the leading
  // colon on the new name.
  rename FOO:sphere2 :BAR:sphere2;
  // Result: BAR:sphere2 //

  // query the current namespace (using the namespaceInfo command)
  namespaceInfo -currentNamespace;
  // Result: FOO //

// remove the namespace FRED (it must be empty)
  namespace -set ":";
  namespace -rm "FRED";

  // Check to see that the FRED namespace has been removed
  namespace -exists ":FRED";
  // Result: 0 //

  // Rename namespace BAR to JOE
  // Note: this is done by creating JOE, moving the contents of
  // BAR into JOE, and then removing the (now empty) BAR.
  namespace -set ":";
  namespace -add "JOE";
  namespace -mv "BAR" "JOE";
  namespace -rm "BAR";

  // JOE should now contain a single node: 'sphere2'.
  // Move the contents of JOE into FRANK, when FRANK already
  // has a 'sphere2' node. The '-force'
  // flag is needed.
  namespace -set ":";
  namespace -add "FRANK";
  namespace -set "FRANK";
  sphere -n "sphere2";
  namespace -force -mv ":JOE" ":FRANK";
  // In moving 'sphere2' from JOE to FRANK it will be renamed to
  // 'sphere3' to ensure uniqueness.
  // The naemspace FRANK should now contain 'sphere2', 'sphere2Shape',
  // and 'sphere3'.