Defines the attachment of a metadata structure to one or more selected objects. This creates a placeholder with an empty metadata Stream for later population through the editMetadatacommand. It’s similar in concept to the addAttrcommand for nodes - a data description is added but no data is actually set. When assigning a metadata structure you must specify these flags - channelNameis the metadata channel type (e.g. “vertex”), streamNameis the name of the metadata stream to be created, and structureis the name of the structure type defining the contents of the metadata. The indexTypeflag is optional. If it is not present then the index will be presumed to be a standard numerical value. You can query metadata information at a variety of levels. See the table below for a full list of the queryable arguments. In each case the specification of any of the non-queried arguments filters the list of metadata to be examined during the query. For all queries a single object must be selected for querying. For example querying the channelNameflag with no other arguments will return the list of all Channel types on the selected object that contain any metadata. Querying the channelNameflag with the indexTypeflag specified will return only those channel types containing metadata streams that use that particular type of index. Query the channelNameflag to return the list of any channel types that have metadata.Specify the channelNameand streamNameflags and query the structureflag to return the name of the structure assigned to the given stream (if any).Specify a channelNameand query the streamNameto return the list of all streams assigned to that particular channel type.If you query the streamNamewithout a specific channelNamethen it returns a list of pairs of (channelName, streamName) for all metadata streams.Flag Combinations: ChannelName IndexType StreamName Structure Create Can Query 0 0 0 0 X ChannelName, StreamName, Structure 0 0 0 1 X ChannelName, StreamName, IndexType 0 0 1 0 X ChannelName, Structure, IndexType 0 0 1 1 X ChannelName, IndexType 0 1 0 0 X ChannelName, StreamName, Structure 0 1 0 1 X ChannelName, StreamName 0 1 1 0 X ChannelName, Structure 0 1 1 1 X ChannelName 1 0 0 0 X StreamName, Structure, IndexType 1 0 0 1 X StreamName, IndexType 1 0 1 0 X Structure, IndexType 1 0 1 1 (a) IndexType 1 1 0 0 X StreamName, Structure 1 1 0 1 X StreamName 1 1 1 0 X Structure 1 1 1 1 (b) X (a) Assign an empty metadata stream with default index type (b) Assign an empty metadata stream with the named index type
Long name (short name) | Argument Types | Properties | |
---|---|---|---|
channelName (cn) | unicode | ||
|
|||
channelType (cht) | unicode | ||
|
|||
indexType (idt) | unicode | ||
Name of the index type the new Channel should be using. If not specified this defaults to a simple numeric index. Of the native types only a mesh “vertexFace” channel is different, using a “pair” index type. In query mode, this flag can accept a value. |
|||
scene (scn) | bool | ||
Use this flag when you want to add metadata to the scene as a whole rather than to any individual nodes. If you use this flag and have nodes selected the nodes will be ignored and a warning will be displayed. |
|||
streamName (stn) | unicode | ||
Name of the empty stream being created. In query mode not specifying a value will return a list of streams on the named channel type. In query mode, this flag can accept a value. |
|||
structure (str) | unicode | ||
Name of the structure which defines the metadata to be attached to the object. In query mode this will return the name of the structure attached at a given stream. In query mode, this flag can accept a value.Flag can appear in Create mode of commandFlag can have multiple arguments, passed either as a tuple or a list. |
Derived from mel command maya.cmds.addMetadata
Example:
import pymel.core as pm
import maya.cmds as cmds
pm.polyPlane( name='p', ch=False )
# Result: [nt.Transform(u'p')] #
pm.select( 'pShape', replace=True )
pm.dataStructure( format='raw', asString='name=IdStruct:int32=ID' )
# Result: u'IdStruct' #
pm.dataStructure( format='raw', asString='name=OffStruct:float=Offset' )
# Result: u'OffStruct' #
pm.dataStructure( format='raw', asString='name=OrgStruct:float[3]=Origin Point' )
# Result: u'OrgStruct' #
# Add three metadata streams
pm.addMetadata( streamName='IdStream', channelName='vertex', structure='IdStruct' )
# Result: [u'pShape'] #
pm.addMetadata( streamName='OffStream', channelName='vertex', structure='OffStruct' )
# Result: [u'pShape'] #
pm.addMetadata( streamName='OrgStream', channelName='edge', structure='OrgStruct' )
# Result: [u'pShape'] #
pm.addMetadata( streamName='VFStream', channelName='vertexFace', indexType='pair', structure='OrgStruct' )
# Result: [u'pShape'] #
# Query for the list of all channel types possessing metadata
pm.addMetadata( query=True, channelName=True )
# Result: [u'edge', u'vertex', u'vertexFace'] #
# Return: ['edge', 'vertex', 'vertexFace'] #
# Query for the structure assigned to a specific stream
pm.addMetadata( channelName='vertex', streamName='OffStream', query=True, structure=True )
# Result: [u'OffStruct'] #
# Return: 'OffStruct' #
# Query for the list of all streams on a specific channel type
pm.addMetadata( channelName='vertex', query=True, streamName=True )
# Result: [u'IdStream', u'OffStream'] #
# Return: ['IdStream', 'OffStream'] #
# Query for the list of all streams
pm.addMetadata( query=True, streamName=True )
# Result: [u'OrgStream', u'IdStream', u'OffStream', u'VFStream'] #
# Return: ['IdStream', 'OffStream', 'OrgStream', 'VFStream'] #
# You can combine queries to answer more general questions about the
# metadata on an object. For example suppose you wanted to know the
# index type used by all Streams on the 'vertex' Channel.
# First extract the list of Streams on the Channel
streams = pm.addMetadata( channelName='vertex', query=True, streamName=True )
# Loop through each Stream, querying the IndexType only for that Stream
for stream in streams:
indexType = pm.addMetadata( channelName='vertex', streamName=stream, query=True, indexType=True )[0]
print 'Index type on %s is %s' % (stream, indexType)