(基于DWGdirect 1.13.02 构建AutoCAD格式文件)
AutoCAD数据库架构:
ACAD文件建立过程:
1. 创建数据库
OdDbDatabasePtr pDwg = CDwgRW::m_Svcs.createDatabase();
......
2. 构建256调色板.
m_aColor[1] = (int)RGB(255,0,0); m_aColor[2] = (int)RGB(255,255,0);
......
m_aColor[254] = (int)RGB(192,192,192); m_aColor[255] = (int)RGB(255,255,255);
........
3. 构建线型表
创建线形,填充线型表
OdDbLinetypeTablePtr pTable;
OdDbLinetypeTableRecordPtr pEntry;
OdDbObjectId id;
pTable = ,_pDwgData->getLinetypeTableId().safeOpenObject(OdDb::kForWrite);
pEntry = OdDbLinetypeTableRecord::createObject();
id = pTable->add(pEntry);
.......
4. 构建图层(略)
5. 构建文字样式(略)
6. 构建尺寸样式(略)
7. 构建块定义及块中实体
创建块(pEntry为用户自定义块)
OdDbBlockTablePtr pTable = _pDwgData->getBlockTableId().safeOpenObject(OdDb::kForWrite);
OdDbBlockTableRecordPtr pEntry = OdDbBlockTableRecord::createObject();
id = pTable->add(pEntry);
往块中加实体
OdDbLinePtr pLine = OdDbLine::createObject();
Id= pEntry ->appendOdDbEntity(pLine);
“块引用”于”块定义”的关联
OdDbBlockReferencePtr pBR = OdDbBlockReference::createObject();
pBR->setBlockTableRecord(objID);
.....&#