ccgt 发表于 2008-1-30 19:50:00

求教一段插入块的代码

<p>各位大虾,下面是我写的一段代码,想实现的功能是在把路径为"D:\\test.dwg"的文件作为块插入到当前的图形中去。</p><p>但是不能成功运行。请指教</p><p>#include "StdAfx.h"<br/>#include "StdArx.h"<br/>#include "aced.h"<br/>#include "migrtion.h"<br/>#include "gemat3d.h "<br/>#include "dbents.h "<br/>//-----------------------------------------------------------------------------<br/>// This is command 'CHARUDWG, by&nbsp; , , <br/>void test1basiccharudwg()<br/>{<br/>#ifdef OARXWIZDEBUG<br/>&nbsp;acutPrintf ("\nOARXWIZDEBUG - test1basiccharudwg() called.");<br/>#endif // OARXWIZDEBUG<br/>&nbsp;&nbsp; // AcGeMatrix3d pt=(0,0,0);</p><p>&nbsp;AcDbDatabase&nbsp; extDb(Adesk::kFalse);&nbsp; //定义一个空数据库</p><p>&nbsp;&nbsp; extDb.readDwgFile("D:\\test.dwg");<br/>&nbsp;&nbsp;&nbsp; AcDbDatabase *ptempdb; <br/>&nbsp;&nbsp;&nbsp; extDb.wblock(ptempdb);<br/>&nbsp;AcDbObjectId&nbsp; blockid;<br/>&nbsp;acdbCurDwg()-&gt;insert(blockid,"kkk",ptempdb);<br/>&nbsp;delete ptempdb;<br/>&nbsp;<br/>&nbsp;AcDbBlockTable *pBlkTbl; <br/>&nbsp;acdbHostApplicationServices()-&gt;workingDatabase()&nbsp;&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp; -&gt;getBlockTable(pBlkTbl, AcDb::kForWrite); </p><p>&nbsp;AcGePoint3d ptInsert(100,100,0); <br/>&nbsp;AcDbBlockReference *pBlkRef = new AcDbBlockReference(ptInsert,blockid);<br/>&nbsp;AcDbBlockTableRecord *pBlkTblRcd; <br/>&nbsp;pBlkTbl-&gt;getAt(ACDB_MODEL_SPACE, pBlkTblRcd, AcDb::kForWrite); <br/>&nbsp; <br/>&nbsp;pBlkTblRcd-&gt;appendAcDbEntity(pBlkRef); <br/>&nbsp;pBlkTbl-&gt;close();<br/>&nbsp;&nbsp;&nbsp; pBlkRef-&gt;close();<br/>&nbsp;pBlkTblRcd-&gt;close();<br/>&nbsp;&nbsp;</p><p>}</p>

nc2t 发表于 2008-2-10 18:19:00

<p>出现什么样的错误啊</p>

xtjtao 发表于 2008-2-26 15:09:00

<p>AcDbDatabase *ptempdb;</p><p>改为:</p><p>AcDbDatabase *ptempdb=new AcDbDatabase;</p><p>即可</p>
页: [1]
查看完整版本: 求教一段插入块的代码