移動先: 概要 戻り値 キーワード. フラグ. Python 例.
nodePreset([attributes=string], [custom=string], [delete=[name, string]], [exists=[name, string]], [isValidName=string], [list=name], [load=[name, string]], [save=[name, string]])
注意: オブジェクト名や引数を表す文字列はカンマで区切ります。これは概要には示されていません。
nodePreset は 「元に戻す」が不可能、「照会」が不可能、「編集」が不可能 です。
ノードのプリセットの設定を保存/ロードするためのコマンドです。
このコマンドで、ノードのすべてのアトリビュート値を記録し、任意の名前を付けてディスクに保存することができます。保存したプリセットをロードし、同じタイプのノードに適用することができます。プリセットを適用したノードの値は、プリセットを生成したノードの、記録した時点での値と同じになります。
boolean | isValidName または exists が使用されているかどうか。 |
preset, render, globals
attributes, custom, delete, exists, isValidName, list, load, save
ロング ネーム(ショート ネーム) |
引数型 |
プロパティ |
save(sv)
|
[name, string]
|
|
|
1 番目の引数で指定したノードのカレントの設定を、2 番目の引数で指定した名前のプリセットに保存します。指定した名前のプリセットがノードに存在する場合、警告メッセージを出すことなく上書きします。-exists フラグを使用して、該当プリセットが存在しているかどうかを確認できます。ノードのアトリビュートがコネクト先の場合は、そのアトリビュート値はプリセットとして書き込まれません。
|
|
load(ld)
|
[name, string]
|
|
|
1 番目の引数で指定したノードの設定を、2 番目の引数で指定したプリセットに従って設定します。コネクト先のノード、あるいはその子(複数の子、あるいは合成された子)は、このプリセットでは変更されません。
|
|
delete(delete)
|
[name, string]
|
|
|
2 番目の引数で指定した名前を持つ、1 番目の引数で指定したノードのプリセットを削除します。
|
|
list(ls)
|
name
|
|
|
指定したノードにロードすることができるすべてのプリセット名をリスト表示します。
|
|
exists(ex)
|
[name, string]
|
|
|
1 番目の引数で指定したノードに 2 番目の引数で指定した名前のプリセットが存在する場合、true を返します。このフラグを使用して、既存のプリセットが上書きされてしまうかどうかを確認でき、上書きしたくない場合は別の名前を付けることができます。
|
|
isValidName(ivn)
|
string
|
|
|
プリセット名を構成する文字がすべて有効であれば true を返します。それ以外の場合には false を返します。プリセット名はファイル名や MEL プロシージャ名の一部になるため、無効な文字も設定されています。プリセット名の有効文字は、英数字とアンダースコアのみです。
|
|
custom(ctm)
|
string
|
|
|
マルチ、ダイナミック アトリビュート、コネクションなどの一般的なプリセットの保存の仕組みによって処理されないノード アトリビュートをカスタムで処理するための MEL スクリプトを指定します。#presetName と #nodeName の識別子は、スクリプトの実行前に展開されます。このスクリプトは、プリセット ファイルに保存され、プリセットを別のノードに適用した際に、これをコマンドとして実行する文字配列を返す必要があります。
このカスタム スクリプトを使用して、プリセットへの保存内容を定義する #nodeName の照会や、プリセットの適用方法を定義するために、選択したノードを照会するコマンドの実行ができます。
|
|
attributes(atr)
|
string
|
|
|
プリセット ファイルに保存する指定アトリビュートの、空白で区切られた文字列です。指定していない場合、すべてのアトリビュートが格納されます。
|
|
: コマンドの作成モードで使用可能なフラグ
|
: コマンドの編集モードで使用可能なフラグ
|
: コマンドの照会モードで使用可能なフラグ
|
: タプルまたはリストとして渡された複数の引数を持てるフラグ
|
import maya.cmds as cmds
# To determine if "My Special Settings" is a valid name for a preset (it
# is not because it contains spaces):
#
cmds.nodePreset(isValidName="My Special Settings" )
# Result: 0 #
# To save the settings of nurbsSphereShape1 as a preset called "smithers":
#
cmds.nodePreset( save=("nurbsSphereShape1","smithers") )
# To get a list of all presets available that could be applied to
# nurbsSphereShape1:
#
cmds.nodePreset( list='nurbsSphereShape1' )
# Result: [u'smithers', u'smoothSphere', u'roughSphere', u'atmoSphere'] #
# To load the preset named "smoothSphere" onto nurbsSphereShape1:
#
cmds.nodePreset( load=('nurbsSphereShape1', 'smoothSphere') )
# To delete the preset named "smithers" which was formerly available for the
# node nurbsSphereShape1 (and other nodes of the same type):
#
cmds.nodePreset( delete=('nurbsSphereShape1', 'smithers') )
# To determine if a preset named "smithers" exists for the node
# nurbsSphereShape1 (it does not because it has been deleted):
#
cmds.nodePreset( exists=('nurbsSphereShape1', 'smithers') )
# Result: 0 #
# Create a preset containing only the color and diffuse attributes:
#
cmds.nodePreset( save=("lambert1","colorAndDiffuse"), attributes='color diffuse' )
# Create a preset to map a checker texture to the applied node.
# Because the "custom" callback is required to return an array of MEL commands,
# each line of python in the array must be wrapped by the MEL "python" command.
#
def customChecker():
doCheckerCmds = [
# Get the name of the node to apply the checker to.
"python( \"selection = cmds.ls( selection=True )\" );",
"python( \"nodeName = selection[0]\" );",
# Create a checker texture.
"python( \"checkerName = cmds.shadingNode( 'checker', asTexture=True )\" );",
# Connect the checker to the node the preset is applied to.
"python( \"cmds.connectAttr( (checkerName+\\\".outColor\\\"), (nodeName+\\\".color\\\") )\" );"
]
return doCheckerCmds
cmds.nodePreset(custom="python( \"customChecker()\" )", save=('lambert1', 'checkered') )