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

Synopsis

hasMetadata([asList=boolean], [channelName=string], [channelType=string], [endIndex=string], [ignoreDefault=boolean], [index=string], [indexType=string], [memberName=string], [scene=boolean], [startIndex=string], [streamName=string])

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

hasMetadata is NOT undoable, NOT queryable, and NOT editable.

This command is used to query for the presence of metadata elements on a node, components, or scene. The command works at all levels of metadata presence, from the existence of any metadata at all on a node or scene right down to the presence of metadata values set on a particular metadata Stream index. Filter Flags

Operation Flags

Return value

string[]List of indexes in the filtered list which contain metadata
boolean[]List of answers to whether the specified item(s) have metadata

Keywords

metadata, component, stream, channel, association

Related

addMetadata, applyMetadata, dataStructure, editMetadata, getMetadata

Flags

asList, channelName, channelType, endIndex, ignoreDefault, index, indexType, memberName, scene, startIndex, streamName
Long name (short name) Argument types Properties
asList(al) boolean create
Use this flag when you want to return string values indicating where the metadata lives rather than boolean values. See the command description for more details on what this flag will return.
ignoreDefault(id) boolean create
Use this flag when you want to skip over any metadata that has only default values. i.e. the metadata may exist but it hasn't had a new value set yet (non-zero for numerics, non-empty strings, etc.) See the command description for more details on how this flag filters the search.
memberName(mn) string create
Name of the Structure member being checked. The names of the members are set up in the Structure definition, either through the description passed in through the "dataStructure" command or via the API used to create that Structure. As the assignment of metadata is on a per-structure basis this flag only needs to be specified when querying for non-default values. If you query for non-default values and omit this flag then it checks that any of the members have a non-default value.
channelName(cn) string createquery
Filter the metadata selection to only recognize metadata belonging to the specified named Channel (e.g. "vertex"). This flag is ignored if the components on the selection list are being used to specify the metadata of interest.

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.

endIndex(eix) string create

The metadata is stored in a Stream, which is an indexed list. If you have mesh components selected then the metadata indices are implicit in the list of selected components. If you select only the node or scene then this flag may be used in conjunction with the startIndex flag to specify a range of indices from which to retrieve the metadata. It is an error to have the value of startIndex be greater than that of endIndex.

See also the index flag for an alternate way to specify multiple indices. This flag can only be used on index types that support a range (e.g. integer values - it makes no sense to request a range between two strings)

In query mode, this flag can accept a value.

index(idx) string createquerymultiuse

In the typical case metadata is indexed using a simple integer value. Certain types of data may use other index types. e.g. a "vertexFace" component will use a "pair" index type, which is two integer values; one for the face ID of the component and the second for the vertex ID.

The index flag takes a string, formatted in the way the specified indexType requires. All uses of the index flag have the same indexType. If the type was not specified it is assumed to be a simple integer value.

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 integer 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.
startIndex(six) string create

The metadata is stored in a Stream, which is an indexed list. If you have mesh components selected then the metadata indices are implicit in the list of selected components. If you select only the node or scene then this flag may be used in conjunction with the endIndex flag to specify a range of indices from which to retrieve the metadata. It is an error to have the value of startIndex be greater than that of endIndex.

See also the index flag for an alternate way to specify multiple indices. This flag can only be used on index types that support a range (e.g. integer values - it makes no sense to request a range between two strings)

In query mode, this flag can accept a value.

streamName(stn) string createquery
Name of the metadata Stream. Depending on context it could be the name of a Stream to be created, or the name of the Stream to pass through the filter.

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='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.select( 'smcPlaneShape', replace=True )
cmds.addMetadata( structure='idStructure', streamName='idStream', channelName='vertex' )
cmds.addMetadata( structure='keyValueStructure', streamName='keyValueStream', channelName='key', indexType='string' )

# Apply the metadata values to three of the components by selection
cmds.select( 'smcPlaneShape.vtx[8:10]', replace=True )
cmds.editMetadata( streamName='idStream', memberName='ID', value=7 )
# Result: 3 #

# Verify existence of the three newly set metadata values at the node level
cmds.select( 'smcPlaneShape', replace=True )
cmds.hasMetadata()
# Result: [True] #

# Verify existence of the three newly set metadata values at the Channel level
cmds.hasMetadata( channelName='vertex' )
# Result: [True] #
cmds.hasMetadata( channelName='edge' )
# Result: [False] #

# Verify existence of the three newly set metadata values at the Stream level
cmds.hasMetadata( channelName='vertex', streamName='idStream' )
# Result: [True] #
cmds.hasMetadata( channelName='edge', streamName='someOtherStream' )
# Result: [False] #

# Verify existence of the three newly set metadata values at the Index level
cmds.hasMetadata( channelName='vertex', streamName='idStream', index=['8','9'] )
# Result: [True, True] #
cmds.hasMetadata( channelName='vertex', streamName='idStream', index=['8','9999'] )
# Result: [True, False] #

# Verify existence of default metadata values at the Index level. Since the
# index range was established to be 0-17 by assignment and the Stream
# defaults to returning default values for unassigned indices the lower index
# values "0" and "1" do have metadata (as default values) but the higher one
# "9999" in the above example does not.
cmds.hasMetadata( channelName='vertex', streamName='idStream', index=['0','1'] )
# Result: [True, True] #

# Verify non-existence of non-default metadata values at the Index level
cmds.hasMetadata( ignoreDefault=True, channelName='edge', streamName='idStream', memberName='ID', index=['0','1'] )
# Result: [False, False] #

# Get the list of Index values with assigned metadata on the object
cmds.select( 'smcPlaneShape.vtx[8:20]', replace=True )
cmds.hasMetadata( channelName='vertex', streamName='idStream', asList=True )
# Result: [u'8', u'9', u'10'] #

# Set metadata values using the complex index type='string'
cmds.editMetadata( streamName='keyValueStream', memberName='value', stringValue='Starry Night', indexType='string', index='Title' )
cmds.editMetadata( streamName='keyValueStream', memberName='value', stringValue='Vincent Van Gogh', indexType='string', index='Artist' )

# Verify existence of the complex index data
cmds.hasMetadata( streamName='keyValueStream', memberName='value', channelName='key', index=['Title','Artist'], indexType='string', asList=True )
# Result: [u'Artist', u'Title'] #