Go to: Synopsis. Return value. Keywords. Related. Flags. Python examples.
applyMetadata([format=string], [scene=boolean], [value=string])
Note: Strings representing object names and arguments must be separated by commas. This is not depicted in the synopsis.
applyMetadata is undoable, NOT queryable, and NOT editable.
Define the values of a particular set of metadata on selected objects.
This command is used in preservation of metadata through Maya file formats
(.ma/.mb). If any metadata already exists it will be kept and merged with
the new metadata, overwriting duplicate entries. (i.e. if this command
specifies data at index N and you already have a value at index N then
the one this command specifies will be the new value and the old one
will cease to exist.)
Unlike the editMetadata command it is not necessary to first use
the addMetadata command or API equivalent to attach a metadata
stream to the object, this command will do both assignment of structure
and of metadata values. You do have to use the dataStructure
command or API equivalent to create the structure being assigned first
though.
The formatted input will be in a form expected by the data
associations serializer (see adsk::Data::AssociationsSerializer for
more information). The specific serialization type will be the default
'raw' if the format flag is not used.
For example the "raw" format input string
"channel face\n[STREAMDATA]\nendChannels\nendAssociations"
with no flags is equivalent to the input "[STREAMDATA]\nendChannels" with
the channel flag set to 'face'
Boolean | True if the application succeeded |
metadata, component, stream, channel, association
addMetadata, dataStructure, editMetadata, getMetadata
format, scene, value
Long name (short name) |
Argument types |
Properties |
format(fmt)
|
string
|
|
|
Name of the data association format type to use in the value flag parsing.
Default value is "raw".
|
|
scene(scn)
|
boolean
|
|
|
Use this flag when you want to apply 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.
|
|
value(v)
|
string
|
|
|
String containing all of the metadata to be assigned to the selected
object.
|
|
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.
|
import maya.cmds as cmds
import maya.cmds as cmds
pNode = cmds.polyPlane( name='p' )
# Create a sample structure
cmds.dataStructure( format='raw', asString='name=IdStruct:int32=ID' )
# Apply some metadata based on the defined structure to the created mesh
# Normally you'll only see these in Maya files but it can be used from the
# command line.
cmds.applyMetadata( pNode, value="channel face\nstream\nIdStream\nIdStruct\n0\n99\n1\n999\n2\n9999\nendStream\nendChannel\nendAssociations" )
# Return: 1 #