ジャンプ先: 概要. 戻り値. キーワード. 関連. フラグ. Python 例.
getMetadata([channelName=string], [channelType=string], [dataType=boolean], [endIndex=string], [index=string], [indexType=string], [listChannelNames=boolean], [listMemberNames=boolean], [listStreamNames=boolean], [memberName=string], [scene=boolean], [startIndex=string], [streamName=string])
注: オブジェクトの名前と引数を表す文字列は、カンマで区切る必要があります。これはシノプシスに示されていません。
getMetadata は、取り消し不可能、照会不可能、および編集不可能です。
このコマンドを使用して、ノードまたはシーンからメタデータ要素の値を取得します。一度に 1 つのストラクチャ メンバーを返すように制限されています。便宜上、必要な詳細は、単一のメタデータ チャネルで 1 つのストラクチャの単一のメンバーを検索するのに十分な情報だけです。
最も単純なケースで、1 つのメタデータ チャネルに 1 つのストリームがあり、メンバーを 1 つだけ持つストラクチャを使用する場合、必要な情報は、メタデータを含むオブジェクトの名前だけです。最も複雑なケースでは、1 つの一意のメンバーにメタデータを絞り込むために、「channelName」、「streamName」、「memberName」のすべてが必要になります。
一般にスクリプトでは、メタデータがどこかに追加される可能性があるため、すべてのフラグを使用することをお勧めします。ショートカットは主に、スクリプト エディタまたはコマンド ラインでコマンドを直接入力するときにすばやく入力するためにあります。
データが存在しない場所でインデックスが指定されると、値がなかったインデックスを通知するメッセージが表示され、コマンドは失敗します。有効なメタデータのある場所を事前に把握しておく必要がある場合は、最初に hasMetadata コマンドを使用してメタデータがある場所を特定します。フィルタ フラグ
- channelName: 特定の 1 つのチャネル タイプのメタデータのみを検索します。
- streamName: 1 つの特定の名前が付けられたストリームのメタデータのみを検索します。channelName と一緒に使用する場合、名前が一致してもチャネル タイプが異なるストリームは無視されます。
- index: ストリームの 1 つまたは複数の特定のインデックス値のメタデータのみを検索します。streamName フラグを使用する必要があります。streamName によって推測されるため、indexType フラグは必要ありません。
- startIndex/endIndex: index と同じですが、インデックス値の 1 つではなく範囲全体を使用します。範囲がサポートされていないインデックス タイプ(例: 文字列)では無効です。
- indexType: 特定のインデックス タイプを使用するメタデータのみを検索します。同様に、その他のフィルタ フラグによって範囲を絞り込むことができます。
- memberName: 取得するストラクチャのメタデータの特定のメンバー。これが指定されていない場合、ストラクチャは 1 つのメンバーのみを持つことができます。
メッシュ上のメタデータは、「vertex」、「edge」、「face」、「vertexFace」のチャネル タイプが同じ名前のコンポーネントに直接接続している点で特殊です。これらのメタデータ チャネルは、channelName および index/startIndex/endIndex フラグを使用せずに、コマンド ライン上で対応するコンポーネントを単に選択または指定することで、より簡単に設定することができます。たとえば、セレクション「myMesh.vtx[8:10]」は、channelName = vertex、および index = 8, 9, 10 (多目的フラグとして)または setIndex = 8, endIndex=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[] | メタデータ メンバーの文字列値のリスト |
metadata, component, stream, channel, association
addMetadata, applyMetadata, dataStructure, editMetadata, hasMetadata
channelName, channelType, dataType, endIndex, index, indexType, listChannelNames, listMemberNames, listStreamNames, memberName, scene, startIndex, streamName
フラグはコマンドの作成モードで表示できます
|
フラグはコマンドの編集モードで表示できます
|
フラグはコマンドの照会モードで表示できます
|
フラグに複数の引数を指定し、タプルまたはリストとして渡すことができます。
|
import maya.cmds as cmds
import maya.cmds as cmds
cmds.polyPlane( name='smcPlane', constructionHistory=False )
# Result: smcPlane #
cmds.pickWalk( d='down' )
# Result: [u'smcPlaneShape'] #
# 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', channelName='vertex' )
cmds.addMetadata( structure='keyValueStructure', streamName='keyValueStream', channelName='key', indexType='string' )
# Set the metadata values on three of the components by selection
cmds.select( 'smcPlaneShape.vtx[8:10]', replace=True )
cmds.editMetadata( 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', channelName='vertex', index=['8','9','10'] )
# Result: [[7], [7], [7]] #
# List stream names of the shape
cmds.select( 'smcPlaneShape', replace=True )
cmds.getMetadata( listStreamNames=True )
# Result: [u'keyValueStream', u'idStream'] #
# List stream names which is in the specified channel
cmds.select( 'smcPlaneShape', replace=True )
cmds.getMetadata( channelName='vertex', listStreamNames=True )
# Result: [u'idStream'] #
# List stream names of the shape which has the specified member
cmds.select( 'smcPlaneShape', replace=True )
cmds.getMetadata( memberName='ID', listStreamNames=True )
# Result: [u'idStream'] #
# List channel names which is used by the specified stream
cmds.select( 'smcPlaneShape', replace=True )
cmds.getMetadata( streamName='idStream', listChannelNames=True )
# Result: [u'vertex'] #
# List channel names which has the specified member
cmds.select( 'smcPlaneShape', replace=True )
cmds.getMetadata( memberName='ID', listChannelNames=True )
# Result: [u'vertex'] #
# List member names which is used by the specified stream
cmds.select( 'smcPlaneShape', replace=True )
cmds.getMetadata( streamName='idStream', listMemberNames=True )
# Result: [u'ID'] #
# Query data type of the listed member
cmds.select( 'smcPlaneShape', replace=True )
cmds.getMetadata( streamName='idStream', listMemberNames=True, dataType=True )
# Result: [u'ID', u'int32'] #
# Query data type of the specified member
cmds.select( 'smcPlaneShape', replace=True )
cmds.getMetadata( streamName='idStream', memberName='ID', dataType=True )
# Result: [u'int32'] #
# 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:10]', replace=True )
cmds.getMetadata( streamName='idStream', memberName='ID' )
# Result: [[0], [7], [7], [7]] #
# Set metadata values using the complex index type stream
cmds.editMetadata( streamName='keyValueStream', memberName='value', stringValue='Starry Night', index='Title' )
# Result: True #
cmds.editMetadata( streamName='keyValueStream', memberName='value', stringValue='Vincent Van Gogh', index='Artist' )
# Result: True #
# Retrieve the complex index data (note return is in alphabetical order of index)
cmds.getMetadata( streamName='keyValueStream', memberName='value', channelName='key', index=['Title', 'Artist'], indexType='string' )
# Result: [['Vincent Van Gogh'], ['Starry Night']] #