打开文件
如何在ARX中不通过文件对话框打开DWG文件并置为当前文档 <TABLE height="100%"><TBODY>
<TR>
<TD colSpan=2><FONT id=text2 style="FONT-SIZE: 10pt" face="宋体,verdana, arial, helvetica">static char pData[] = "C:\\test.dwg";<BR><BR>void openSyncDoc()<BR>{<BR>AcApDocument* pDoc = acDocManager->curDocument();<BR>if (pDoc) <BR>{<BR>acutPrintf("\nCurrently in Document context : %s, Switching to App.\n",pDoc->fileName());<BR>acDocManager->executeInApplicationContext(openSyncDocHelper, (void *)pData);<BR>} <BR>acDocManager->activateDocument(pDoc);<BR>acDocManager->closeDocument(pDoc); <BR>} <BR><BR>void openSyncDocHelper( void *pData)<BR>{<BR>AcApDocument* pDoc = acDocManager->curDocument();<BR>if (acDocManager->isApplicationContext()) <BR>{<BR>acutPrintf("\nSucessfully Switched to App. Context\n");<BR>acDocManager->appContextOpenDocument((const char *)pData);<BR>acutPrintf("\nOpened a document synchronously:%s.\n", (const char *)pData);<BR>} <BR>else<BR>acutPrintf("\nERROR: in Document context : %s\n",pDoc->fileName());<BR>}</FONT> </TD></TR>
<TR>
<TD vAlign=bottom colSpan=2><BR></TD></TR></TBODY></TABLE> acDocManager->appContextOpenDocument("你要打开的文件名和路径");只要打开后就置为当前了。我觉得这样做很简单,你可以试试
页:
[1]