|
- acDocManager->lockDocument(curDoc());
- // 获得当前图形数据库的块表
- AcDbBlockTable *pBlkTbl;
- acdbHostApplicationServices()->workingDatabase()
- ->getBlockTable(pBlkTbl, AcDb::kForWrite);
- // 创建新的块表记录
- AcDbBlockTableRecord *pBlkTblRcd;
- pBlkTblRcd = new AcDbBlockTableRecord();
- // 设置块表记录的名称
- CString blkName = "DiagramTail";
- pBlkTblRcd->setName(blkName);
- // 将块表记录添加到块表中
- AcDbObjectId blkDefId;
- pBlkTbl->add(blkDefId, pBlkTblRcd);
- pBlkTbl->close();
- // 向块表记录中添加线段
- AcGePoint3d RectLD(0,0,0), RectLU(0,18,0), RectRD(390,0,0), RectRU(390,18,0);
- drawLine(RectLD, RectLU, pBlkTblRcd);
- drawLine(RectLD, RectRD, pBlkTblRcd);
- drawLine(RectRU, RectLU, pBlkTblRcd);
- drawLine(RectRU, RectRD, pBlkTblRcd);
- //下面添加文字
- RectLU.y = RectRU.y = 2.5;
- AcGePoint3d ptInsertText(10,3,0);
- CString tempText = "制 图";
- drawText(ptInsertText,tempText, pBlkTblRcd);
- pBlkTblRcd->close();
- // 查找用户指定的块定义是否存在
- if (!pBlkTbl->has(blkName.AllocSysString()))
- {
- acutPrintf(采用T("\n当前图形中未包含指定名称的块定义!"));
- pBlkTbl->close();
- return;
- }
- AcGePoint3d ptInsert(25,5,0);
- // 获得用户指定的块表记录
- pBlkTbl->getAt(blkName.AllocSysString(), blkDefId);
- AcDbBlockReference *pBlkRef = new AcDbBlockReference(ptInsert,blkDefId);
- pBlkTbl->getAt(ACDB采用MODEL采用SPACE, pBlkTblRcd,AcDb::kForWrite);
- AcDbObjectId entId;
- pBlkTblRcd->appendAcDbEntity(entId, pBlkRef);
- // 关闭数据库的对象
- pBlkRef->close();
- pBlkTblRcd->close();
- pBlkTbl->close();
- acDocManager->unlockDocument(curDoc());
复制代码 |
|