 |
 |
 |
Python Computer Graphics Kit |
 |
 |
 |
The MAReader class reads Maya ASCII files and calls
appropriate methods which have to be implemented in a derived class.
The content of the file is actually a subset of the Maya Embedded
Language (MEL) which is the scripting language implemented inside
Maya. The MAReader parses the file, breaks down the content
of the file in commands and their arguments and options (expressions
are not evaluated). Each MEL command will then trigger a callback
method that has to execute the command. These callback methods have
to be implemented in a derived class.
There are 12 MEL commands that can appear in a Maya ASCII
file4.2:
- file
- requires
- fileInfo
- currentUnit
- createNode
- setAttr
- addAttr
- connectAttr
- disconnectAttr
- parent
- select
- lockNode
Each command has a number of arguments and can also take options. The
callback methods receive the arguments as regular arguments to the
method and the options as an additional argument opts which is
a dictionary containing the options that were specified in the
file. The key is the long name of the option (without leading dash)
and the value is a list of strings containing the option values. The
number of values and how they have to be interpreted depend on the
actual option.
-
Creates an instance of the reader.
- filename
-
The file name (if it could be obtained). This may be used for generating
warning or error messages.
- linenr
-
The current line number. This may be used for generating warning or error
messages.
-
Aborts reading the current file.
This method can be called in handler methods to abort reading the file.
-
Read the content of a file. f is either a file like object that
can be used to read the content of the file or the name of a file.
-
Callback method that is called before the file is read.
-
Callback method that is called after the file was read.
-
Reference an external file.
| onRequires( |
product, version) |
-
Specify a requirement that is needed to load the file properly.
product is a string containing the required software component
and version is a string containing the required version of that
component.
| onFileInfo( |
keyword, value, opts) |
-
Specifies information about the file. keyword and value
are both strings.
-
Specify the units (linear, angular, time) used in the file.
| onCreateNode( |
nodetype, opts) |
-
Create a new node. nodetype is a string specifying the type of node
that is to be created. The new node will automatically be selected (i.e.
subsequent setAttr commands refer to this node).
| onSetAttr( |
attr, vals, opts) |
-
Set a node attribute. attr is a string containing the attribute
to be set. vals is a list of values. The number of elements and
the type of each element depends on the attribute.
-
Add a new attribute to the node.
| onConnectAttr( |
srcattr, dstattr, opts) |
-
Connect two attributes. srcattr is a string specifiying the
attribute that serves as a source and dstattr is the name of
the attribute that will receive the value.
| onDisconnectAttr( |
srcattr, dstattr, opts) |
-
Break the attribute connection between two attributes.
| onParent( |
objects, parent, opts) |
-
Set the parent of one or more nodes. objects is a list of node names
and parent the name of the parent.
-
Select a node from a referenced file. objects is a list of strings
containing the node names.
| onLockNode( |
objects, opts) |
-
Lock/unlock a node. objects is a list of strings containing the node
names (the list may be empty).
Footnotes
- ...
file4.2
- Actually, there could appear any MEL command, but at least
Maya will only export files containing the above commands.
Release 2.0.0alpha8, documentation updated on February 24, 2008.