| MPxMayaAsciiFilter () | |
| ~MPxMayaAsciiFilter () | |
| haveWriteMethod () const | |
| haveReadMethod () const | |
| reader ( const MFileObject & file , const MString & optionsString, FileAccessMode mode) | |
| writer ( const MFileObject & file , const MString & optionsString, FileAccessMode mode) |
| file () const | |
| processReadOptions (const MString & optionsString) | |
| processWriteOptions (const MString & optionsString) | |
| writesRequirements ( ) const | |
| writesCreateNode ( const MObject & node ) const | |
| writesSetAttr ( const MPlug & srcPlug ) const | |
| writesConnectAttr ( const MPlug & srcPlug, const MPlug & destPlug ) const | |
| writesDisconnectAttr ( const MPlug & srcPlug, const MPlug & destPlug ) const | |
| writesParentNode ( const MDagPath & parent, const MDagPath & child ) const | |
| writesSelectNode ( const MObject & node ) const | |
| writesFileReference ( const MFileObject & referenceFile ) const | |
| writePostHeader ( MPxMayaAsciiFilterOutput& fileIO ) | |
| writePostRequires ( MPxMayaAsciiFilterOutput& fileIO ) | |
| writePreCreateNodesBlock ( MPxMayaAsciiFilterOutput& fileIO ) | |
| writePostCreateNodesBlock ( MPxMayaAsciiFilterOutput& fileIO ) | |
| writePreConnectAttrsBlock ( MPxMayaAsciiFilterOutput& fileIO ) | |
| writePostConnectAttrsBlock ( MPxMayaAsciiFilterOutput& fileIO ) | |
| writePreTrailer ( MPxMayaAsciiFilterOutput& fileIO ) |
| MFileKind | |
| FileAccessMode | |
| MPxFileTranslator () | |
| ~MPxFileTranslator () | |
| reader ( const MFileObject & file, const MString & optionsString, FileAccessMode mode) | |
| writer ( const MFileObject & file, const MString & optionsString, FileAccessMode mode) | |
| haveReadMethod () const | |
| haveWriteMethod () const | |
| haveNamespaceSupport () const | |
| haveReferenceMethod () const | |
| defaultExtension () const | |
| filter () const | |
| canBeOpened () const | |
| identifyFile ( const MFileObject & file, const char* buffer, short size) const | |
| fileAccessMode () |
MyAsciiFilter::writer(...)
{
// do something before writing to file here
...
// we will now write to the file
MStatus result = MPxMayaAsciiFilter::reader(...);
if (result == MStatus::kSuccess)
{
... // do something after writing the file here
}
return result;
}
To determine if a given line should be output, override the methods
writesCreateNode(), writesSetAttr() and so on. Each of these methods
takes as its arguments the relevant data which is about to be processed,
and your plug-in can use this to determine whether or not the line will
be output.For example, you may want to write out everything but render layer data.
The code to do this might look something like what is shown here:
bool
MyAsciiFilter::writesCreateNode( const MObject& node )
{
if (node.hasFn(MFn::kRenderLayer))
{
return true;
}
return false;
}
bool
MyAsciiFilter::writesConnectAttr( const MPlug& srcPlug,
const MPlug& destPlug )
{
if (srcPlug.node().hasFn(MFn::kRenderLayer) ||
dstPlug.node().hasFn(MFn::kRenderLayer))
{
return true;
}
return false;
}
Note that writesConnectAttr() has to be overridden as well (as would
writesSetAttr(), writesSelectAttr(), and so on). This is because each line is
handled separately, and nothing clever is done in the base class' implementation
of writesConnectAttr(), such as having a default behaviour of only outputting
connectAttrs for nodes that are being output. This gives you the most flexible
control over what will and will not be written.If you were using this class to save a segmented file, a master file might have
to know about the locations of each of the segments. If your file saved everything
but render layers in one file, and render layers in another, the first file might
need to contain a pointer to the second, so that when the first file's loaded the
second gets read into memory, too. To do this, you would use MPxMayaAsciiFilter's
ability to write directly to the stream during file output.You can write to the stream during output by overriding the methods
writePreCreateNodesBlock(), writePostCreateNodesBlock() and so on. These give
you a simple mechanism to write directly to the file. Each of these methods
take an MPxMayaAsciiFilterOutput as its only argument. To write to the file,
simply use the output operator (MPxMayaAsciiFilterOutput::operator<<() )
and output the string you wish.In the example above, the pointer to the render layer file might be inserted into
the main file after all nodes have been created. The code to do this would look
something like what is shown here:
MStatus
MyAsciiFilter::writePostCreateNodesBlock( MPxMayaAsciiFilterOutput& fileIO )
{
fileIO << "exec(\"importRenderLayerFile \"MyLayerFile.maf\";\")\n";
}
In the above example, after the createNode block was output, the line
exec("importRenderLayerFile "MyLayerFile.maf");
is output. When the file is read in, Maya would reach the line above and execute
it like any other MEL command. It is assumed in this example that there would be
a custom command plug-in called importRenderLayerFile which would do the work
of actually importing the layer file.Note:
MPxMayaAsciiFilter gives you the ability to create your own custom file formats
based on standard Maya ASCII files. However, Alias does not support such custom
files as they will not, by definition, be standard Maya ASCII files.
| Autodesk® Maya® 2008 © 1997-2007 Autodesk, Inc. All rights reserved. | doc++ Copyright |