Maya C++ API - export to 2 formats at once


#1

Hello,

in my export plugin I would like to have an opportunity to export a scene in 2 formats. But I don’t know if this is possible. I want to have 2 formats in the list which drops down when you choose File Type when zou click on Export Selected.

For export to only one format I do:

MString x3dExporter::defaultExtension () const
{
    return "x3d";
}

MStatus initializePlugin(MObject obj)
{
   
   MFnPlugin plugin(obj, PLUGIN_COMPANY, "4.0", "Any");
			plugin.registerFileTranslator( "x3d", 
											"",
											x3dExporter::creator,
											"",
											"option1=1",
											true);    
	return MStatus::kSuccess;
}

MStatus uninitializePlugin(MObject obj)
{
   MStatus status;
   MFnPlugin plugin(obj);

   status = plugin.deregisterCommand("x3dExporter");

   if (!status)
   {
      status.perror("deregisterCommand");
      return status;
   }

   return status;
}

MStatus x3dExporter::writer ( const MFileObject& file,
                                const MString& options,
                                FileAccessMode mode )

{
   MStatus status;
    
    MString mname = file.fullName(), unitName;
    const char *fname = mname.asChar();
    fp = fopen(fname,"w");
	

	 if( ( mode == MPxFileTranslator::kExportAccessMode ) ||
        ( mode == MPxFileTranslator::kSaveAccessMode ) )
    {
        exportAll();
    }
    else if( mode == MPxFileTranslator::kExportActiveAccessMode )
    {
        exportSelected();
    }
    
		fclose(fp);

    return MS::kSuccess;
}

I thought that I can only make another registration in the initializePlugin method. But how will the writer method know which format is chosen? Maybe I am doing it all the way wrong…