gg850416 发表于 2008-7-24 16:22:00

新建DWG文挡

<p><font color="#ee1111">#include "StdAfx.h"<br/>#include "StdArx.h"<br/>#include "dbsymtb.h"<br/>#include "dbents.h"</font></p><p><font color="#ee1111">//-----------------------------------------------------------------------------<br/>// This is command 'NEWDOC, by&nbsp; , , <br/>void ACADnewdoc()<br/>{<br/>#ifdef OARXWIZDEBUG<br/>&nbsp;acutPrintf ("\nOARXWIZDEBUG - ACADnewdoc() called.");<br/>#endif // OARXWIZDEBUG</font></p><p><font color="#ee1111">&nbsp;// TODO: Implement the command<br/>&nbsp;static char pData[] ="acad.dwt"; <br/>&nbsp;acDocManager-&gt;executeInApplicationContext(CreateDoc, (void *)pData);</font></p><p><font color="#ee1111">&nbsp;AcDbDatabase *pdb =acdbHostApplicationServices()-&gt;workingDatabase();</font></p><p><font color="#ee1111">&nbsp;AcDbBlockTable *pBtbl;<br/>&nbsp;&nbsp;&nbsp; pdb-&gt;getSymbolTable(pBtbl, AcDb::kForRead);</font></p><p><font color="#ee1111">&nbsp;&nbsp;&nbsp; AcDbBlockTableRecord *pBtblRcd;<br/>&nbsp;&nbsp;&nbsp; pBtbl-&gt;getAt(ACDB_MODEL_SPACE, pBtblRcd,<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AcDb::kForWrite);<br/>&nbsp;&nbsp;&nbsp; pBtbl-&gt;close();</font></p><p><font color="#ee1111">&nbsp;&nbsp;&nbsp; AcDbCircle *pCir1 = new AcDbCircle(AcGePoint3d(1,1,1),<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AcGeVector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pCir2-&gt;close();<br/>&nbsp;&nbsp;&nbsp; pBtblRcd-&gt;close();</font></p><p><font color="#ee1111">}</font></p><p><font color="#ee1111">void CreateDoc( void *pData) <br/>{ <br/>&nbsp;AcApDocument* pDoc = acDocManager-&gt;curDocument(); <br/>&nbsp;if(acDocManager-&gt;isApplicationContext()) <br/>&nbsp;{<br/>&nbsp; acDocManager-&gt;appContextNewDocument((const char *)pData); <br/>&nbsp;} <br/>&nbsp;else<br/>&nbsp; acutPrintf("\nERROR To Create Doc!\n");<br/>}</font></p><p><font color="#ee1111"></font></p><p><font color="#ee1111"><font color="#3d11ee">上述代码执行后,圆并未画在新建出来的DWG文挡上,而画在了前一个DWG文挡上,这样新建的DWG并不是当前的WorkingDatabase</font>
                </font></p>
页: [1]
查看完整版本: 新建DWG文挡