#include <MPxFileTranslator.h>
This class provides the connection to Maya by which user written file translators can be added as plug-ins.
This class provides a base class from which one derives in order to implement Maya "File Translator Plug-Ins." A file translator plug-in allows Maya to read or write 3rd party file formats.
The identifyFile method is called whenever Maya's file save or restore dialogs are run, and identifyFile uses the filename and first few bytes of the file to determine whether it is of a type supported by the translator. If it is, then Maya will display the file with the "name" and "icon" specified as arguments to MFnPlugin::registerFileTranslator.
If an attempt is made to read the file, the "reader" method in the derived class is called, if an attempt is made to write the file, the "writer" method is called.
Type of file access.
MPxFileTranslator::MPxFileTranslator | ( | ) |
The class constructor.
MPxFileTranslator::~MPxFileTranslator | ( | ) | [virtual] |
The class destructor.
MStatus MPxFileTranslator::reader | ( | const MFileObject & | file, | |
const MString & | optionsString, | |||
MPxFileTranslator::FileAccessMode | mode | |||
) | [virtual] |
This routine is called by Maya when it is necessary to load a file of a type supported by this translator.
This virtual method must be overloaded in derived classes, as the default version defined in MPxFileTranslator simply fails unconditionally. The only parameter is an MFileObject that contains the pathname of the file to be loaded. This routine is responsible for reading the contents of the given file, and creating Maya objects via API or MEL calls to reflect the data in the file.
[in] | file | the name of the file to read |
[in] | optionsString | a string representation of any file options |
[in] | mode | the method used to read the file - open or import |
Reimplemented in MPxMayaAsciiFilter.
MStatus MPxFileTranslator::writer | ( | const MFileObject & | file, | |
const MString & | optionsString, | |||
MPxFileTranslator::FileAccessMode | mode | |||
) | [virtual] |
This routine is called by Maya when it is necessary to save a file of a type supported by this translator.
This virtual method must be overloaded in derived classes, as the default version defined in MPxFileTranslator simply fails unconditionally. The only parameter is an MFileObject that contains the pathname of the file to be written to. This routine is responsible for traversing all objects in the current Maya scene, and writing a representation to the given file in the supported format.
It is not essential that all information in the current Maya scene be written out, although if it is not, the scene will not be recreated when this file is read via the "reader" method.
[in] | file | the name of the file to write |
[in] | optionsString | a string representation of any file options |
[in] | mode | the method used to write the file - save, export, or export active. |
Reimplemented in MPxMayaAsciiFilter.
bool MPxFileTranslator::haveReadMethod | ( | ) | const [virtual] |
This routine is called by Maya while it is executing in the MPxFileTranslator constructor. Maya uses this entry point to query the translator and determine if it provides a reader method.
This virtual method must be overloaded in derived classes if a reader method exists, as the default version defined in MPxFileTranslator unconditionally returns false.
Reimplemented in MPxMayaAsciiFilter.
bool MPxFileTranslator::haveWriteMethod | ( | ) | const [virtual] |
This routine is called by Maya while it is executing in the MPxFileTranslator constructor. Maya uses this entry point to query the translator and determine if it provides a write method.
This virtual method must be overloaded in derived classes if a writer method exists, as the default version defined in MPxFileTranslator unconditionally returns false.
Reimplemented in MPxMayaAsciiFilter.
bool MPxFileTranslator::haveNamespaceSupport | ( | ) | const [virtual] |
When a file is imported or referenced into an existing scene, there is the possibility that nodes in the incoming file will have the same names as nodes already in the scene. Although DAG nodes may legally have the same name so long as their DAG paths are different, in all other cases node names must be unique.
Maya has a number of different algorithms which the user may select to resolve name clashes. (See the file command for more details.) Some of these algorithms involve creating a separate namespace for the incoming file and placing some or all of its nodes within that namespace.
As some translators may have difficulty dealing with namespaces, Maya will first call the translator's haveNamespaceSupport() method to see if it can handle them.
If the user requests that namespaces be used to resolve clashes and the translator does not support namespaces, then Maya will simply place all incoming nodes into the default namespace and it will be up to the translator to ensure that no clashes occur, otherwise there will be errors during the import/reference.
If a translator can deal with having Maya placing some or all of a file's nodes into a separate namespace, then its derived class should override this virtual method to return true.
By default the method returns false.
bool MPxFileTranslator::haveReferenceMethod | ( | ) | const [virtual] |
This routine is called by Maya while it is executing in the MPxFileTranslator constructor. Maya uses this entry point to query the translator and determine if it provides a reference method.
This virtual method must be overloaded in derived classes if a writer method exists, as the default version defined in MPxFileTranslator unconditionally returns false.
MString MPxFileTranslator::defaultExtension | ( | ) | const [virtual] |
This routine is called by Maya whenever it needs to know the default extension of a translator.
This virtual method may be overloaded in derived classes if a default extension exists, as the default version defined in MPxFileTranslator unconditionally returns an empty string.
MString MPxFileTranslator::filter | ( | ) | const [virtual] |
This virtual method may be overloaded in a derived class to set the filter extension that will be used by the file dialog. If this method is not implemented in a derived class, the standard filter *.* will be returned by MPxFileTranslator and used by the file dialog.
bool MPxFileTranslator::canBeOpened | ( | ) | const [virtual] |
This routine is called by Maya while it is executing in the MPxFileTranslator constructor. Maya uses this entry point to query the translator and determine if it can open files. The default is true.
MPxFileTranslator::MFileKind MPxFileTranslator::identifyFile | ( | const MFileObject & | file, | |
const char * | buffer, | |||
short | size | |||
) | const [virtual] |
This routine is called by Maya when a file selection dialog accesses a new directory. It will potentially be called once for every file in the directory.
The routine is given an MFileObject indicating the file being checked, as well as a pointer to the initial file contents. The size parameter indicates the number of bytes available at the pointer location.
This routine must use this data to determine if the file is of a type supported by this translator. This virtual method must be overloaded in derived classes, as the default version defined in MPxFileTranslator unconditionally returns kNotMyFileType.
A typical use of this method is to check the file extension of the file in question, and return a status indicating whether or not the file is of the type expected by this MPxFileTranslator. See the plugin example animImportExport for an example.
[in] | file | the name of the file to check |
[in] | buffer | a pointer to the initial contents of the file |
[in] | size | the number of valid bytes in the buffer |
MPxFileTranslator::FileAccessMode MPxFileTranslator::fileAccessMode | ( | ) | [static] |
This routine returns the fileAccess mode maya is currently in.
Autodesk® Maya® 2009 © 1997-2008 Autodesk, Inc. All rights reserved. | Generated with 1.5.6 |