yusongrong 发表于 2004-11-19 23:17:00

如何实现在new AcDbDatabase里插入一个外部图块?

AcDbDatabase *pDb = new AcDbDatabase();        <BR>AcDbBlockTable *pBtbl;<BR>pDb-&gt;getSymbolTable(pBtbl, AcDb::kForRead);        <BR>AcDbBlockTableRecord *pBtblRcd;<BR>pBtbl-&gt;getAt(ACDB_MODEL_SPACE, pBtblRcd,AcDb::kForWrite); <BR>pBtbl-&gt;close();       


AcDbDatabase *pNewDb =new AcDbDatabase(Adesk::kFalse); <BR>//acDocManager-&gt;lockDocument(acDocManager-&gt;curDocument()) ;                <BR>int es=pNewDb-&gt;readDwgFile(sFileName , _SH_DENYNO,false); <BR>if (es!=Acad::eOk) <BR>{ <BR>        acutPrintf("\nThe file %s cannot be opend",sFileName); <BR>        return; <BR>}                       <BR>pDb-&gt;insert(AcGeMatrix3d::kIdentity, pNewDb);<BR>        <BR>pBtblRcd-&gt;close();                       <BR>pDb-&gt;saveAs(DwgName);<BR>delete pDb;


上面代码无法实现在new AcDbDatabase里插入一个外部图块,请高手指教如何实现?

王咣生 发表于 2004-11-20 13:14:00

回复

参考:



AcDbDatabase *pNewDb =new AcDbDatabase(Adesk::kFalse); <BR>int es=pNewDb-&gt;readDwgFile(sFileName);<BR>if (es!=Acad::eOk) <BR>{ <BR>        acutPrintf("\nThe file %s cannot be opend",sFileName); <BR>        return; <BR>}                       


AcDbObjectId id ;<BR>pDb-&gt;insert (id,"myfile", pNewDb , Adesk::kFalse) ;<BR><BR>delete pNewDb ;

yusongrong 发表于 2004-11-21 22:45:00

好象不行啊?


AcDbDatabase *pDb = new AcDbDatabase();        <BR>AcDbBlockTable *pBtbl;<BR>pDb-&gt;getSymbolTable(pBtbl, AcDb::kForRead);        <BR>AcDbBlockTableRecord *pBtblRcd;<BR>pBtbl-&gt;getAt(ACDB_MODEL_SPACE, pBtblRcd,<BR>                               AcDb::kForWrite); <BR>pBtbl-&gt;close();


AcDbDatabase *pNewDb =new AcDbDatabase(Adesk::kFalse); <BR>int es=pNewDb-&gt;readDwgFile(sFileName);<BR>if (es!=Acad::eOk) <BR>{ <BR>               acutPrintf("\nThe file %s cannot be opend",sFileName); <BR>               return; <BR>}                       <BR>        <BR>AcDbObjectId id ;<BR>pDb-&gt;insert (id,"myfile", pNewDb , Adesk::kFalse) ;        <BR>delete pNewDb ;                <BR>pBtblRcd-&gt;close();                       <BR>pDb-&gt;saveAs(DwgName);<BR>delete pDb;

pengst 发表于 2004-11-22 00:06:00

图块应理解为"对定义的引用",外部的图块必须在当前图中生成块定义后才能在当前中使用,

yusongrong 发表于 2004-11-22 21:04:00

没有啊,下面的代码可以将外部的DWG文件插入当前数据库:


AcDbDatabase *pNewDb =new AcDbDatabase(Adesk::kFalse); <BR>acDocManager-&gt;lockDocument(acDocManager-&gt;curDocument()) ;<BR>int es=pNewDb-&gt;readDwgFile(sFileName , _SH_DENYNO,false); <BR>if (es!=Acad::eOk) <BR>{ <BR>        acutPrintf("\nThe file %s cannot be opend",sFileName); <BR>        return; <BR>}                       <BR>AcDbDatabase *pDb; <BR>pDb =acdbHostApplicationServices ()-&gt;workingDatabase () ;                       <BR>pDb-&gt;insert(AcGeMatrix3d::kIdentity, pNewDb);<BR>return;
页: [1]
查看完整版本: 如何实现在new AcDbDatabase里插入一个外部图块?