移動先: 概要 注記. 戻り値 フラグ. Python 例.

概要

rename( [object] string , [ignoreShape=boolean])

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

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

指定したオブジェクトが新しい名前に変更されます。引数を 1 つだけ指定すると、最初に選択したオブジェクトの名前が変更されます。新しい名前が既存の名前と同じ場合は、指定した名前に基づいて固有の名前がオブジェクトに付きます。 オブジェクトの名前を空の文字列にすることはできません。

トランスフォーム名を変更すると、そのトランスフォームの下にあるシェイプ ノードのうち、プリフィックスが古いトランスフォーム名と同じものは名前が変更されます。たとえば「rename nurbsSphere1 ball」では、「nurbsSphere1|nurbsSphereShape1」が「ball|ballShape」に変更されます。

新しい名前の最後に「#」を 1 つ付けると、名前の変更コマンドは、新しい名前を固有にする番号で最後の「#」を置き換えます。

注記

名前を変更するオブジェクトの名前を明示的に指定すると、この名前はルート ネームスペースを基準にして定義されます。ただし、新しい名前は、カレント ネームスペースを基準にして定義されます。 下の例を参照してください。

戻り値

string新しい名前。元に戻した場合、オリジナルの名前が返されます。

フラグ

ignoreShape
ロング ネーム(ショート ネーム) 引数型 プロパティ
ignoreShape(ignoreShape) boolean create
トランスフォームの下にあるシェイプ ノードの名前を変更しないように指定します。

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

Python 例

import maya.cmds as cmds

# create two namespaces under the root namespace and create
# a sphere under the root namespace and a sphere under one
# of the new namespaces.
cmds.namespace( set=':' )
cmds.sphere( n='sphere1' )
cmds.namespace( add='nsA' )
cmds.namespace( add='nsB' )
cmds.namespace( set='nsA' )
cmds.sphere( n='sphere2' )
cmds.namespace( set=':' )
# change name of sphere1
cmds.rename('sphere1', 'spinning_ball')

# change name of spinning_ball back to sphere1
cmds.select( 'spinning_ball', r=True )
cmds.rename( 'sphere1' )

# move sphere2 to namespace nsB
cmds.rename( 'nsA:sphere2', 'nsB:sphere2' )
# Result: nsB:sphere2 #

# move sphere2 back to namespace nsA when not in the root namespace
# Note the ":" appearing in front of the new name to indicate
# we want to move the object to namespace nsA under the root namespace.
cmds.namespace( set='nsB' )
cmds.rename( 'nsB:sphere2', ':nsA:sphere2' )
# Result: nsA:sphere2 #

# Let's try this without the leading ":" in the new name.
# Since we are namespace nsA, in affect, what we are trying to do
# is rename :nsB:sphere2 to :nsA:nsB:sphere3. Since there isn't a
# nsB namespace under the namespace nsA, the namespace specification
# on new name is ignored and a warning is issued.
cmds.namespace( set=':nsA' )
cmds.rename( 'nsA:sphere2', 'nsB:sphere3' )
# Warning: Removing invalid characters from name. #
# Result: nsA:sphere3 #

# rename an object when not in the root namespace
# and move the object to current namespace
cmds.namespace( set=':nsB' )
cmds.rename( 'nsA:sphere3', 'sphere4' )
# Result: nsB:sphere4 #