ジャンプ先: 概要. 注. 戻り値. フラグ. Python 例.
rename(
[object] string
, [ignoreShape=boolean], [uuid=boolean])
注: オブジェクトの名前と引数を表す文字列は、カンマで区切る必要があります。これはシノプシスに示されていません。
rename は、取り消し可能、照会不可能、および編集不可能です。
指定したオブジェクトが新しい名前に変更されます。引数を 1 つだけ指定すると、最初に選択したオブジェクトの名前が変更されます。新しい名前が既存の名前と同じ場合は、指定した名前に基づいて固有の名前がオブジェクトに付きます。オブジェクトの名前を空の文字列にすることはできません。トランスフォーム名を変更すると、そのトランスフォームの下にあるシェイプ ノードのうち、プリフィックスが古いトランスフォーム名と同じものは名前が変更されます。たとえば「rename nurbsSphere1 ball」では、「nurbsSphere1|nurbsSphereShape1」が「ball|ballShape」に変更されます。
新しい名前の最後に「#」を 1 つ付けると、名前の変更コマンドは、新しい名前を固有にする番号で最後の「#」を置き換えます。
string | 新しい名前。元に戻した場合、オリジナルの名前が返されます。 |
ロング ネーム(ショート ネーム) | 引数タイプ | プロパティ | ||
---|---|---|---|---|
ignoreShape(ignoreShape)
|
boolean
|
![]() |
||
|
||||
uuid(uid)
|
boolean
|
![]() |
||
|
![]() |
![]() |
![]() |
![]() |
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 # # rename an object with an absolute name to move it into a new namespace. # The namespace does not exist so will be created. cmds.namespace( set=':nsB' ) cmds.rename( 'nsA:sphere3', ':nsC:sphere4' ) # Result: nsC:sphere4 #