如何实现在new AcDbDatabase里插入一个外部图块?
AcDbDatabase *pDb = new AcDbDatabase(); <BR>AcDbBlockTable *pBtbl;<BR>pDb->getSymbolTable(pBtbl, AcDb::kForRead); <BR>AcDbBlockTableRecord *pBtblRcd;<BR>pBtbl->getAt(ACDB_MODEL_SPACE, pBtblRcd,AcDb::kForWrite); <BR>pBtbl->close();AcDbDatabase *pNewDb =new AcDbDatabase(Adesk::kFalse); <BR>//acDocManager->lockDocument(acDocManager->curDocument()) ; <BR>int es=pNewDb->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->insert(AcGeMatrix3d::kIdentity, pNewDb);<BR> <BR>pBtblRcd->close(); <BR>pDb->saveAs(DwgName);<BR>delete pDb;
上面代码无法实现在new AcDbDatabase里插入一个外部图块,请高手指教如何实现?
回复
参考:AcDbDatabase *pNewDb =new AcDbDatabase(Adesk::kFalse); <BR>int es=pNewDb->readDwgFile(sFileName);<BR>if (es!=Acad::eOk) <BR>{ <BR> acutPrintf("\nThe file %s cannot be opend",sFileName); <BR> return; <BR>}
AcDbObjectId id ;<BR>pDb->insert (id,"myfile", pNewDb , Adesk::kFalse) ;<BR><BR>delete pNewDb ; 好象不行啊?
AcDbDatabase *pDb = new AcDbDatabase(); <BR>AcDbBlockTable *pBtbl;<BR>pDb->getSymbolTable(pBtbl, AcDb::kForRead); <BR>AcDbBlockTableRecord *pBtblRcd;<BR>pBtbl->getAt(ACDB_MODEL_SPACE, pBtblRcd,<BR> AcDb::kForWrite); <BR>pBtbl->close();
AcDbDatabase *pNewDb =new AcDbDatabase(Adesk::kFalse); <BR>int es=pNewDb->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->insert (id,"myfile", pNewDb , Adesk::kFalse) ; <BR>delete pNewDb ; <BR>pBtblRcd->close(); <BR>pDb->saveAs(DwgName);<BR>delete pDb; 图块应理解为"对定义的引用",外部的图块必须在当前图中生成块定义后才能在当前中使用, 没有啊,下面的代码可以将外部的DWG文件插入当前数据库:
AcDbDatabase *pNewDb =new AcDbDatabase(Adesk::kFalse); <BR>acDocManager->lockDocument(acDocManager->curDocument()) ;<BR>int es=pNewDb->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 ()->workingDatabase () ; <BR>pDb->insert(AcGeMatrix3d::kIdentity, pNewDb);<BR>return;
页:
[1]