zhubohobby 发表于 2005-3-9 09:11:00

打开文件

如何在ARX中不通过文件对话框打开DWG文件并置为当前文档

梦幻神话 发表于 2005-3-9 10:21:00

<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-&gt;curDocument();<BR>if (pDoc) <BR>{<BR>acutPrintf("\nCurrently in Document context : %s, Switching to App.\n",pDoc-&gt;fileName());<BR>acDocManager-&gt;executeInApplicationContext(openSyncDocHelper, (void *)pData);<BR>} <BR>acDocManager-&gt;activateDocument(pDoc);<BR>acDocManager-&gt;closeDocument(pDoc); <BR>} <BR><BR>void openSyncDocHelper( void *pData)<BR>{<BR>AcApDocument* pDoc = acDocManager-&gt;curDocument();<BR>if (acDocManager-&gt;isApplicationContext()) <BR>{<BR>acutPrintf("\nSucessfully Switched to App. Context\n");<BR>acDocManager-&gt;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-&gt;fileName());<BR>}</FONT> </TD></TR>
<TR>
<TD vAlign=bottom colSpan=2><BR></TD></TR></TBODY></TABLE>

JA_JERRY 发表于 2005-3-10 10:48:00

acDocManager-&gt;appContextOpenDocument("你要打开的文件名和路径");只要打开后就置为当前了。我觉得这样做很简单,你可以试试
页: [1]
查看完整版本: 打开文件