求教一段插入块的代码
<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 , , <br/>void test1basiccharudwg()<br/>{<br/>#ifdef OARXWIZDEBUG<br/> acutPrintf ("\nOARXWIZDEBUG - test1basiccharudwg() called.");<br/>#endif // OARXWIZDEBUG<br/> // AcGeMatrix3d pt=(0,0,0);</p><p> AcDbDatabase extDb(Adesk::kFalse); //定义一个空数据库</p><p> extDb.readDwgFile("D:\\test.dwg");<br/> AcDbDatabase *ptempdb; <br/> extDb.wblock(ptempdb);<br/> AcDbObjectId blockid;<br/> acdbCurDwg()->insert(blockid,"kkk",ptempdb);<br/> delete ptempdb;<br/> <br/> AcDbBlockTable *pBlkTbl; <br/> acdbHostApplicationServices()->workingDatabase() <br/> ->getBlockTable(pBlkTbl, AcDb::kForWrite); </p><p> AcGePoint3d ptInsert(100,100,0); <br/> AcDbBlockReference *pBlkRef = new AcDbBlockReference(ptInsert,blockid);<br/> AcDbBlockTableRecord *pBlkTblRcd; <br/> pBlkTbl->getAt(ACDB_MODEL_SPACE, pBlkTblRcd, AcDb::kForWrite); <br/> <br/> pBlkTblRcd->appendAcDbEntity(pBlkRef); <br/> pBlkTbl->close();<br/> pBlkRef->close();<br/> pBlkTblRcd->close();<br/> </p><p>}</p> <p>出现什么样的错误啊</p> <p>AcDbDatabase *ptempdb;</p><p>改为:</p><p>AcDbDatabase *ptempdb=new AcDbDatabase;</p><p>即可</p>
页:
[1]