Hello everyone,
I am trying to add some options to the export. In my script I add some Radiobuttons to the export menu. And now when I am trying to pass the chosen values Maya crashes. And I cannot figure out where the problem is… And even though i make default precision is float8 the radiobutton is look loke nothing was chosen at all.
I will be grateful for any advice.
D.
There is my MEL script:
global proc int exportOptions ( string $parent,
string $action,
string $initialSettings,
string $resultCallback )
{
int $bResult;
string $currentOptions;
string $optionList[];
string $optionBreakDown[];
int $index;
if ($action == "post") {
setParent $parent;
columnLayout -adj true objTypeCol;
string $Float8 = (uiRes("m_exportOptions.kFloat8"));
string $Double17 = (uiRes("m_exportOptions.kDouble17"));
radioButtonGrp
-label (uiRes("m_exportOptions.kPrecision"))
-nrb 2 -cw3 175 75 75
-labelArray2 $Float8 $Double17 precision;
// Now set to current settings.
$currentOptions = $initialSettings;
if (size($currentOptions) > 0) {
tokenize($currentOptions, ";", $optionList);
for ($index = 0; $index < size($optionList); $index++) {
tokenize($optionList[$index], "=", $optionBreakDown);
if ($optionBreakDown[0] == "precision") {
if ($optionBreakDown[1] == "0") {
radioButtonGrp -e -sl 2 precision;
} else {
radioButtonGrp -e -sl 1 precision;
}
}
}
}
$result = 1;
} else if ($action == "query") {
if (`radioButtonGrp -q -sl precision` == 1) {
$currentOptions = $currentOptions + "precision=8";
} else {
$currentOptions = $currentOptions + "precision=17";
}
eval($resultCallback+" \""+$currentOptions+"\"");
$result = 1;
} else {
$bResult = 0;
}
text -label "In case of editing an object's vertex of a basic shape" ;
text -label " ";
text -label " please be sure that you have done";
text -label " ";
text -label "Delete by Type: History in the Edit menu
";
text -label " ";
text -label " ";
text -label " ";
return $bResult;
}
exportOptions.res.mel:
displayString -replace -value "Precision:" m_exportOptions.kPrecision;
displayString -replace -value "Float (8)" m_exportOptions.kFloat8;
displayString -replace -value "Double (17)" m_exportOptions.kDouble17;
In the cpp:
const char *const x3dOptionScript = "exportOptions";
const char *const x3dDefaultOptions = "precision=8;";
bool precision8, precision17;
MStatus initializePlugin(MObject obj)
{
MFnPlugin plugin(obj, PLUGIN_COMPANY, "4.0", "Any");
plugin.registerFileTranslator( "x3d",
"none",
x3dExporter::creator,
(char *)x3dOptionScript,
x3dDefaultOptions);
return MStatus::kSuccess;
}
MStatus x3dExporter::writer ( const MFileObject& file,
const MString& options,
FileAccessMode mode )
{
MStatus status;
if (options.length() > 0) {
int i, length;
// Start parsing.
MStringArray optionList;
MStringArray theOption;
options.split(';', optionList); // break out all the options.
length = optionList.length();
for( i = 0; i < length; ++i ){
theOption.clear();
optionList[i].split( '=', theOption );
if( theOption[0] == MString("precision") && theOption.length() > 1 ) {
if( theOption[1].asInt() > 0 ){
precision8 = true;
}else{
precision17 = true;
}
}
}
}
if( ( mode == MPxFileTranslator::kExportAccessMode ) ||
( mode == MPxFileTranslator::kSaveAccessMode ) )
{
exportAll();
}
else if( mode == MPxFileTranslator::kExportActiveAccessMode )
{
exportSelected();
}
fclose(fp);
return MS::kSuccess;
}