[3DS MAX] C++ SDK - Get last "Save As" location

,

Hello all,

I’m currently tinkering with both the 3DS Max and FBX SDKs, creating a custom FBX extension plugin to export custom data from a .max into a separate file, alongside the resulting FBX file.

So I have a DLL project using the FBX SDK that looks a lot like:

extern "C"
{
    //The DLL is owner of the plug-in
    static MaxExtensionTemplatePlugin* sPlugin = NULL;

    //This function will be called when an application will request the plug-in
    FBXSDK_DLLEXPORT void FBXPluginRegistration(FbxPluginContainer& pContainer, FbxModule pFbxModule)
    {
        if( sPlugin == NULL )
        {
            //Create the plug-in definition which contains the information about the plug-in
            FbxPluginDef sPluginDef;
            sPluginDef.mName = "MaxExtensionTemplatePlugin";
            sPluginDef.mVersion = "1.0";

            //Create an instance of the plug-in.  The DLL has the ownership of the plug-in
            sPlugin = MaxExtensionTemplatePlugin::Create(sPluginDef, pFbxModule);

            //Register the plug-in
            pContainer.Register(*sPlugin);
        }
    }
	FBXSDK_DLLEXPORT bool MaxExt_IsExtension(){return true;}
	FBXSDK_DLLEXPORT bool MaxExt_ExportHandled(INode* pMaxObject);
	FBXSDK_DLLEXPORT void MaxExt_ExportBegin(FbxScene* pFbxScene, INode* pMaxRootNode);
    FBXSDK_DLLEXPORT bool MaxExt_ExportProcess(FbxObject** pOutputFbxObject, ReferenceTarget* pMaxObject, FbxScene* pFbxScene);
	FBXSDK_DLLEXPORT void MaxExt_ExportTranslated(FbxObject* pFbxObject, INode* pMaxObject);
	FBXSDK_DLLEXPORT void MaxExt_ExportEnd(FbxScene* pFbxScene, INode* pMaxRootNode);
	FBXSDK_DLLEXPORT bool MaxExt_ImportHandled(FbxObject* pFbxObject);
	FBXSDK_DLLEXPORT void MaxExt_ImportBegin(FbxScene* pFbxScene, INode* pMaxRootNode);
    FBXSDK_DLLEXPORT bool MaxExt_ImportProcess(ReferenceTarget** pOutputObject, FbxObject* pInputFbxObject, bool pIsAnInstance, bool pMerge);
	FBXSDK_DLLEXPORT void MaxExt_ImportTranslated(FbxObject* pFbxObject, INode* pMaxObject);
	FBXSDK_DLLEXPORT void MaxExt_ImportEnd(FbxScene* pFbxScene, INode* pMaxRootNode);
}

My access points are in the implementations of these functions, where I can access pretty much anything in the max C++ API.

The problem is: I cannot access the user’s last export location. When users use “3Max Menu> Export > Export Selected…”, the “Save As” dialog that pops up is still controlled by max and should set the resulting path somewhere in the C++ API? I’ve looked at the autodesk documentation and tried several things myself, but the closest thing I can get is just the current .max file by doing

FbxString sPath = GetCOREInterface()->GetCurFilePath();

Which doesn’t get me what I need, most other path-related queries are very static (IPathConfigMgr…).

My temporary ugly solution is to have this executed at the beginning of the export, which means the user is selecting a target output directory twice.

	// Temp until we can figure out how to get the save file location...
	// Execute MAX Script that pops a save dialog: user picks a directory (same as export). Return value is saved in myVal.
	FPValue myVal;
	ExecuteMAXScriptScript(L"getSavePath caption:\"Export directory\" initialDir:(getDir #maxroot)", 0, &myVal);
	FbxString sExportDir = M2A(myVal.s);

Is there any way I can query the max api for the last “Save As” location (whatever the source, be it Saving, Importing, Exporting, etc.) ? What about from the FBX SDK (also a dead end from my tests)?

Thanks in advance,
p1nkzz