怎么样将数据库中不同的对象另存为不同的dwg文件?
比如将直线和文本存为不同的dwg文件!谢谢!我试一试!
你这样试试
1、新建若干空数据库,并打开块表记录,准备写入。AcDbDatabase dbLine=new AcDbDatabase(true,true);//新建空数据库,第二个参数用true,新数据库不取得焦点
AcDbBlockTable *pLineBlk;
dbLine->getBlockTable(pLineBlk,AcDb::kForRead);
AcDbBlockTableRecord *pLineRcd;
pLineBlk->getAt(ACDB_MODAL_SPACE,pLineRcd,AcDb::kForWrite);
pLineBlk->close();
AcDbDatabase dbText=new AcDbDatabase(true,true);
AcDbBlockTable *pTextBlk;
dbText->getBlockTable(pTextBlk,AcDb::kForRead);
AcDbBlockTableRecord *pTextRcd;
pTextBlk->getAt(ACDB_MODAL_SPACE,pTextRcd,AcDb::kForWrite);
pTextBlk->close();
2、打开源数据库,浏览源数据库的对象,根据不同对象类型向不同的数据库中添加对象。
AcDbDataBase dbResource=new AcDbDatabase;//默认AcDbDatabase构造函数,新数据库为当前文档
dbResource->readDwgFile("源数据库.dwg");
AcDbBlockTable *pBlkTbl;
dbResource->getBlockTable(pBlkTbl,AcDb::kForRead);
AcDbBlockTableRecord *pBlkTblRcd;
pBlkTbl->getAt(ACDB_MODAL_SPACE,pBlkTblRcd,AcDb::kForRead);
pBlkTbl->close();
AcDbBlockTableRecordIterator *pBlkItr;
pBlkTblRcd->newIterator(pBlkItr);
AcDbEntity *pEnt;
for(pBlkItr->start();!pBlkItr->done();pBlkItr->step())
{
pBlkItr->getEntity(pEnt,AcDb::kForRead);
if(pEnt->isKindof(AcDbLine::desc())
pLineRcd->appendAcDbEntity(pEnt);
elseif(pEnt->isKindof(AcDbText::desc())
pTextRcd->appendAcDbEntity(pEnt);
pEnt->close();
}
pBlkTblRcd->close();
pLineRcd->close();
pTextRcd->close();
delete pBlkItr;
delete dbResource;
3、保存新数据库。
dbLine->saveAs("直线.dwg");
dbLine->close();
dbText->saveAs("文字.dwg");
dbText->close();
页:
[1]