Go to: Synopsis. Return value. Keywords. Related. Flags. Python examples.

Synopsis

addMetadata([channelName=string], [channelType=string], [indexType=string], [scene=boolean], [streamName=string], [structure=string])

Note: Strings representing object names and arguments must be separated by commas. This is not depicted in the synopsis.

addMetadata is undoable, queryable, and NOT editable.

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 editMetadata command. It's similar in concept to the addAttr command for nodes - a data description is added but no data is actually set.

When assigning a metadata structure you must specify these flags - channelName is the metadata channel type (e.g. "vertex"), streamName is the name of the metadata stream to be created, and structure is the name of the structure type defining the contents of the metadata. The indexType flag 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 channelName flag with no other arguments will return the list of all Channel types on the selected object that contain any metadata. Querying the channelName flag with the indexType flag specified will return only those channel types containing metadata streams that use that particular type of index.

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

Return value

string[]List of nodes to which a new Stream was successfully added (create mode)
string[]List of channel types containing metadata on an object when querying the channelName flag
string[]List of stream names on an object when querying the streamName flag
string[]List of structures used by an object's metadata Streams when querying the structure flag
string[]List of index types used by an object when querying the indexType flag

In query mode, return type is based on queried flag.

Keywords

metadata, component, stream, channel, association

Related

applyMetadata, dataStructure, editMetadata, getMetadata

Flags

channelName, channelType, indexType, scene, streamName, structure
Long name (short name) Argument types Properties
channelName(cn) string createquery
Name of the Channel type to which the structure is to be added (e.g. "vertex").

In query mode, this flag can accept a value.

channelType(cht) string createquery
Obsolete - use the 'channelName' flag instead.

In query mode, this flag can accept a value.

indexType(idt) string createquery
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) boolean createquery
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) string createquery
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) string createquery
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 command Flag can appear in Edit mode of command
Flag can appear in Query mode of command Flag can have multiple arguments, passed either as a tuple or a list.

Python examples

import maya.cmds as cmds

import maya.cmds as cmds
cmds.polyPlane( name='p', ch=False )
cmds.select( 'pShape', replace=True )
cmds.dataStructure( format='raw', asString='name=IdStruct:int32=ID' )
cmds.dataStructure( format='raw', asString='name=OffStruct:float=Offset' )
cmds.dataStructure( format='raw', asString='name=OrgStruct:float[3]=Origin Point' )
# Add three metadata streams
cmds.addMetadata( streamName='IdStream', channelName='vertex', structure='IdStruct' )
cmds.addMetadata( streamName='OffStream', channelName='vertex', structure='OffStruct' )
cmds.addMetadata( streamName='OrgStream', channelName='edge', structure='OrgStruct' )
cmds.addMetadata( streamName='VFStream', channelName='vertexFace', indexType='pair', structure='OrgStruct' )
# Query for the list of all channel types possessing metadata
cmds.addMetadata( query=True, channelName=True )
# Return: ['edge', 'vertex', 'vertexFace'] #
# Query for the structure assigned to a specific stream
cmds.addMetadata( channelName='vertex', streamName='OffStream', query=True, structure=True )
# Return: 'OffStruct' #
# Query for the list of all streams on a specific channel type
cmds.addMetadata( channelName='vertex', query=True, streamName=True )
# Return: ['IdStream', 'OffStream'] #
# Query for the list of all streams
cmds.addMetadata( query=True, streamName=True )
# 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 = cmds.addMetadata( channelName='vertex', query=True, streamName=True )
# Loop through each Stream, querying the IndexType only for that Stream
for stream in streams:
	indexType = cmds.addMetadata( channelName='vertex', streamName=stream, query=True, indexType=True )[0]
	print 'Index type on %s is %s' % (stream, indexType)