In porting code from Select to CONNECT< I have a tool that uses mdlSystem_newDesignFile(). I'm attempting to replace the use of that function with ISessionMgr calls. I can only get a new .dgn file to open in "read-only" mode. I know there are a few situations that result in a file being opened "read only" but they don't apply (at least I don't think they do).
// BeFileName outFileName; if ( SUCCESS != mdlFile_find(&outFileName, fullFileName.c_str(), NULL, NULL)) { wprintf(L"Error locating file\n"); } else { // open the file StatusInt status; DgnDocumentMonikerPtr dgnMon = DgnDocumentMoniker::CreateFromFileName(fullFileName.c_str()); if (!dgnMon.IsValid()) { wprintf(L"!dgnMon.IsValid()\n"); return true; } DgnDocumentPtr dgnDoc = DgnDocument::CreateFromMoniker(status, *dgnMon, DEFDGNFILE_ID, DgnDocument::FetchMode::Write, DgnDocument::FetchOptions::Default); DgnFilePtr dgnFile = NULL; if (dgnDoc.IsValid()) { wprintf(L"dgnDoc.IsValid()\n"); DgnFileStatus dgnStatus; DgnFilePtr newFile = ISessionMgr::GetManager().FindDesignFile(dgnStatus, fullFileName.c_str(), L"Default", GRAPHICSFILE_UStn, true); if (dgnStatus == SUCCESS) { DgnFileP pFile = ISessionMgr::GetManager().GetMasterDgnFile(); ISessionMgr::GetManager().SwitchToNewFile(*dgnDoc, L"Default", GRAPHICSFILE_UStn, true, false, false, false); } return true; } }
The current (active) file and the one I'm trying to open are not the same file.
Bruce
Bruce Reeves SRNS said: I'm attempting to replace the use of [mdlSystem_newDesignFile] with ISessionMgr calls
mdlSystem_newDesignFile
Why?
Regards, Jon Summers LA Solutions
I figure that [eventually] the "mdlXXX" functions will all be deprecated in favor of the newer MicroStation API classes, plus I just want to know how to do it....
Bruce Reeves SRNS said:I figure that [eventually] the "mdlXXX" functions will all be deprecated in favor of the newer MicroStation API classes
You're probably correct, and at that point (after you've installed the SDK for some future CONNECT Update N) your code using mdlSystem_newDesignFile will fail to compile and you can look for the method of whatever class implements the equivalent functionality.
I wouldn't be too concerned about this. Most of the mdl functions that could no longer be supported have already been removed or had their parameters changed. It's just not worth trying to expunge every mdl function from MicroStation and it's applications; if it ain't broke don't fix it...
I think you can call DgnDocument::CreateForLocalFile?
MSCORE_EXPORT int mdlSystem_newDesignFile (WCharCP fileName) { return ISessionMgr::GetManager().NewDesignFile (*DgnDocument::CreateForLocalFile(fileName), NULL, false); }
OK - I'll stick with mdlSystem_newDesignFile().
Brien Bastings said: ISessionMgr::GetManager().NewDesignFile (*DgnDocument::CreateForLocalFile(fileName), NULL, false);
BTW: I don't see that function in the API documentation.