ジャンプ先: 概要. 戻り値. キーワード. 関連. フラグ. Python 例.
getMetadata([channelType=string], [endIndex=int], [index=string], [indexType=string], [memberName=string], [startIndex=int], [streamName=string])
注: オブジェクトの名前と引数を表す文字列は、カンマで区切る必要があります。これはシノプシスに示されていません。
getMetadata は、取り消し不可能、照会不可能、および 編集不可能 です。
このコマンドを使用してノードからメタデータ要素の値を取得します。以下の 2 つの基本バリエーションがあります。
2 つの方法の違いは、最初の方法がメッシュ コンポーネントに関するある特定の知識(つまり、リーガル インデックス値)を使用する点です。たとえば、14 のエッジを持つメッシュで、エッジ インデックス 15 に対応するメタデータを要求すると、そのようなメタデータが存在する場合でも警告が生成されます。一般的なメタデータの場合、または既知のコンポーネント タイプに関連付けられていないメッシュ メタデータの場合でも、そのような警告が生成されることはありません。これは、関連付けられたデータの境界が不明であるためです。
コンポーネント単位のメタデータにアクセスする一般的な方法は、取得対象のメタデータを持つコンポーネントをコマンド ライン上で選択または指定する方法です。コマンドの 1 回の呼び出しで許可されるコンポーネント タイプは 1 つです。
一般的な使用法では、特定のメタデータを channelType および metadataIndex/startMetadataIndex/endMetadataIndex フラグを使用して選択します。metadataIndex は多目的フラグのため、このフラグを使用して同じチャネルから複数の異なる要素を選択したり、setMetadataIndex/endMetadataIndex のペアを使用して取得するインデックス値の全体の範囲を指定することができます。
metadataIndex フラグは、どのタイプのインデックスでも機能します。既定では、単純な数値インデックスに設定されます。metadataIndexType フラグを指定すると、他のインデックス タイプ(「string」など)を使用できます。 コースの startMetadataIndex フラグと endMetadataIndex フラグは、単純な数値インデックス タイプでのみ機能します。
メッシュ上のメタデータは、「vertex」、「edge」、「face」、「vertexFace」のチャネル タイプが同じ名前のコンポーネントに直接接続している点で特殊です。これらのメタデータ チャネルは、channelType および metadataIndex/startMetadataIndex/endMetadataIndex フラグを使用せずに、コマンド ライン上で対応するコンポーネントを単に選択または指定することで、より簡単に設定することができます。たとえば、「myMesh.vtx[8:10]」は、channelType = vertex、および metadataIndex = 10, 8, 10 (多目的フラグとして)または setMetadataIndex = 8, endMetadataIndex=10 のいずれかに対応します。
1 回のコマンドで許可されるノード、コンポーネント タイプ、チャネル タイプ、値タイプはそれぞれ 1 つだけです。複数の構造体メンバの値を取得するにはコマンドを複数回コールする必要がありますが、この方法によってデータをシンプルに保つことができます。
データが返されると、インデックス順序でメンバ全体が一緒に表示されます。たとえば、3 つのコンポーネントで float[3] メタデータを取得する場合、9 つの値が次の順序で返されます。index[0]-float[0]、index[0]-float[1]、index[0]-float[2]、index[1]-float[0]、index[1]-float[1]、index[1]-float[2]、index[2]-float[0]、index[2]-float[1]、index[2]-float[2]。Python の実装では、float[3] 値はそれぞれ配列となるため、3 つの float[3] 配列が返されます。
int[] | メタデータ メンバの整数値のリスト |
float[] | メタデータ メンバの実数値のリスト |
string[] | メタデータ メンバの文字列値のリスト |
ロング ネーム(ショート ネーム) | 引数タイプ | プロパティ | ||
---|---|---|---|---|
channelType(cht)
|
string
|
![]() |
||
|
||||
memberName(mn)
|
string
|
![]() |
||
|
||||
index(idx)
|
string
|
![]() ![]() |
||
|
||||
indexType(idt)
|
string
|
![]() |
||
|
||||
startIndex(six)
|
int
|
![]() |
||
|
||||
endIndex(eix)
|
int
|
![]() |
||
|
||||
streamName(stn)
|
string
|
![]() |
||
|
![]() |
![]() |
![]() |
![]() |
import maya.cmds as cmds import maya.cmds as cmds cmds.polyPlane( name='smcPlane', constructionHistory=False ) # Result: smcPlane # # Create structures cmds.dataStructure( format='raw', asString='name=idStructure:int32=ID' ) # Result: idStructure # cmds.dataStructure( format='raw', asString='name=keyValueStructure:string=value' ) # Result: keyValueStructure # # Apply structures to plane cmds.addMetadata( structure='idStructure', streamName='idStream', channelType='vertex' ) cmds.addMetadata( structure='keyValueStructure', streamName='keyValueStream', channelType='key', indexType='string' ) # Get the metadata values from three of the components by selection cmds.select( 'smcPlaneShape.vtx[8:10]', replace=True ) cmds.getMetadata( streamName='idStream', memberName='ID', value=7 ) # Result: 1 # # Retrieve the three newly set metadata values cmds.select( 'smcPlaneShape', replace=True ) cmds.getMetadata( streamName='idStream', memberName='ID', channelType='vertex', index=['8','9','10'] ) # Result: [[7], [7], [7]] # # Get metadata from a larger group of indices all at once. # Note that unassigned metadata values assume the default (0 for numbers). cmds.select( 'smcPlaneShape.vtx[7:11]', replace=True ) cmds.getMetadata( streamName='idStream', memberName='ID' ) # Result: [[0], [7], [7], [7], [0]] # # Set metadata values using the complex index type stream cmds.editMetadata( streamName='keyValueStream', memberName='value', stringValue='Starry Night', metadataIndex='Title' ) # Result: 1 # cmds.editMetadata( streamName='keyValueStream', memberName='value', stringValue='Vincent Van Gogh', metadataIndex='Artist' ) # Result: 1 # # Retrieve the complex index data cmds.getMetadata( streamName='keyValueStream', memberName='value', channelType='key', index=['Title', 'Artist'], indexType='string' ) # Result: [['Starry Night'], ['Vincent Van Gogh']] #