void OpenDoc( void *pData);
int COpDwg_OpenOtherDwg(CString strNewFileName) { SErrorInfo errInfo; struct resbuf resSysVal; bool bTmp; AcApDocument* pDoc;
try { //Early work errInfo.strCallFuncName = "COpDwg_OpenOtherDwg"; strNewFileName.TrimLeft(); strNewFileName.TrimRight(); //システム変数初期设定(SDI) CSysDa_InitThisVal("SDI",false,resSysVal); //一时的にMDIモードに设定する(SDIモードだとファイルをオープンする际に例外発生) CSysDa_SetSysValue(0, true, bTmp);
pDoc = acDocManager->curDocument(); acDocManager->activateDocument(pDoc, Adesk::kTrue); if(bSave == true) { acDocManager->sendStringToExecute( pDoc, "(vl-load-com)(vl-cmdf \"vbastmt\" (strcat \"ThisDrawing.Close True\"))\n", false, true);
} else { acDocManager->sendStringToExecute( pDoc, "(vl-load-com)(vl-cmdf \"vbastmt\" (strcat \"ThisDrawing.Close False\"))\n", false, true);
} pDoc = NULL; pDoc = acDocManager->curDocument(); acDocManager->activateDocument(pDoc, Adesk::kTrue); acDocManager->executeInApplicationContext(OpenDoc, (void *)(LPSTR)(LPCTSTR)strNewFileName); return RTN_TRUE; } catch(...) { errInfo.strErrMsg = ERR_MSG_EXCEPTION; goto SystemError; }
SystemError: CError_WriteErrlog(errInfo); return RTN_SYSERR; }
void OpenDoc( void *pData) { AcApDocument* pDoc = acDocManager->curDocument();
if (acDocManager->isApplicationContext()) { acDocManager->appContextOpenDocument((const char *)pData); } else { acutPrintf("\nERROR To Open Doc!\n"); } }
憋了这么多天终于有了点眉目,这段代码想要实现的功能是:将当前活动文件删除,并以strNewFileName路径名打开一个文件.现在在执行了sendStringToExecute后,再执行executeInApplicationContext,就会出现异常,我很不理解,还请哪位高手多多指点一下呀 |