MEL How-To #68
How do I specify the options for an Export plug-in (a.k.a. File Translator)?
The options string is generated by the MEL script that is defined as the "Options" MEL script for the Export type. The exact name of this file is arbitrary and is specified within the exporter plug-in.
For example, the OBJ exporter uses "objExportOptions.mel" to display its options for the user. During an Export, Maya calls this script in two modes: "post" and "query". In "post" mode the "objExportOptions" script populates the "File Type Specific Options" layout of the Export Options panel, setting all UI elements to their current values (or defaults for the first time the Exporter is run). In "query" mode the script reads the settings for the options set by the user and concatenates all options in the form:
To communicate the options between the Exporter and the options panel, Maya saves them in an optionVar. The name of this optionVar is defined within "pv_performAction.mel" as "<exportType>Options". In the case of the OBJ exporter, an optionVar with the name "OBJexportOptions" is created. To query the current state of the options:
optionVar -q OBJexportOptions; // Result: groups=1;ptgroups=0;materials=0;smoothing=0;normals=0 //
To build the 'file' command to perform an "Export All" function:
file -typ <exportType> -op <optionsString> -ea $theFile;
As a real-world example:
string $exportType = "OBJexport"; string $optionsString = `optionVar -q OBJexportOptions`; string $theFile = "D:/AW/user/projects/foo.obj"; file -typ $exportType -op $optionsString -ea $theFile;
For "Export Selected":
file -typ <exportType> -op <optionsString> -es $theFile;
In my experience, the OBJexport file translator makes no distinction between Export All and Export Selected -- it always assumes an Export All. Of course, your in-house Exporters will be smarter than this, right?
Armed with this information you are able to use the options as defined in the Exporter panel. But what if you want to define them yourself?
Firstly, you will need to know the names of all of the options. Secondly, you will need to know what values are valid for its corresponding name. These can be gleaned in one of two ways:
The latter of these two will provide a more complete assessment of the options and how each's corresponding value is derived.
Tuesday, July 17, 2001
|Copyright ©2005 by Bryan Ewert, email@example.com|
Maya is a Registered Trademark of Alias