pymel.core.modeling.applyMetadata

applyMetadata(*args, **kwargs)

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 editMetadatacommand it is not necessary to first use the addMetadatacommand 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 dataStructurecommand 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 formatflag is not used. For example the “raw” format input string “channel facen[STREAMDATA]nendChannelsnendAssociations” with no flags is equivalent to the input “[STREAMDATA]nendChannels” with the channelflag set to ‘face’

Flags:
Long name (short name) Argument Types Properties
format (fmt) unicode ../../../_images/create.gif
 
Name of the data association format type to use in the value flag parsing. Default value is “raw”.
scene (scn) bool ../../../_images/create.gif
 

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) unicode ../../../_images/create.gif
 

String containing all of the metadata to be assigned to the selected object.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.applyMetadata

Example:

import pymel.core as pm

import maya.cmds as cmds
pNode = pm.polyPlane( name='p' )
# Create a sample structure
pm.dataStructure( format='raw', asString='name=IdStruct:int32=ID' )
# Result: u'IdStruct' #
# 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.
pm.applyMetadata( pNode, value="channel face\nstream\nIdStream\nIdStruct\n0\n99\n1\n999\n2\n9999\nendStream\nendChannel\nendAssociations" )
# Return: 1 #

Previous topic

pymel.core.modeling.angleBetween

Next topic

pymel.core.modeling.arcLengthDimension

Core

Core Modules

Other Modules

This Page