- 积分
- 1101
- 明经币
- 个
- 注册时间
- 2009-3-26
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2010-12-15 13:51:48
|
显示全部楼层
稍微改了一下代码,没发现什么太大的错误。
我测试了一下,可以实现填充。
由于没有办法发图片,所以就不给你截图了。- static void Test(void)
- {
- // Add your code for command TestReadDWG.test3 here
- AcDbHatch* pHatch = new AcDbHatch();
- AcGeVector3d normal(0.0, 0.0, 1.0);
- pHatch->setNormal(normal);
- pHatch->setElevation(0.0);
- // pHatch->setAssociative(Adesk::kFalse);
- pHatch->setPattern(AcDbHatch::kPreDefined, _T("SOLID"));
- // pHatch->setStyle(AcDbHatch::kNormal);
- AcGePoint3d start022(120,100,0);
- AcGePoint3d end022(180,100,0);
- AcDbLine*a1Line=new AcDbLine(start022,end022);
- AcDbObjectId ida1Line = AcDbObjectId::kNull;
- postToModel(ida1Line,a1Line);
- //水沟右深度
- AcGePoint3d start032(180,100,0);
- AcGePoint3d end032(180,160,0);
- AcDbLine*b1Line=new AcDbLine(start032,end032);
- AcDbObjectId idb1Line = AcDbObjectId::kNull;
- postToModel(idb1Line,b1Line);
- //水沟下宽度
- AcGePoint3d start042(180,160,0);
- AcGePoint3d end042(120,160,0);
- AcDbLine*c1Line=new AcDbLine(start042,end042);
- AcDbObjectId idc1Line = AcDbObjectId::kNull;
- postToModel(idc1Line,c1Line);
- //水沟左直边
- AcGePoint3d start052(120,160,0);
- AcGePoint3d end052(120,100,0);
- AcDbLine*d1Line=new AcDbLine(start052,end052);
- AcDbObjectId idd1Line = AcDbObjectId::kNull;
- postToModel(idd1Line,d1Line);
-
- AcDbObjectIdArray objIds;
- objIds.append(ida1Line);
- objIds.append(idb1Line);
- objIds.append(idc1Line);
- objIds.append(idd1Line);
- pHatch->appendLoop(AcDbHatch::kExternal, objIds);
- // Construct a circle
- // Elaborate solid fill
- pHatch->evaluateHatch();
- // Post hatch entity to database
- AcDbObjectId objId = AcDbObjectId::kNull;
- postToModel(objId,pHatch);
-
- }
- } ;
- Acad::ErrorStatus postToModel(AcDbObjectId& objId, AcDbEntity* pEnt)
- {
- Acad::ErrorStatus es = Acad::eOk;
- AcDbBlockTable *pBlockTable;
- acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pBlockTable, AcDb::kForRead);
- AcDbBlockTableRecord *pBlockTableRecord;
- pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord, AcDb::kForWrite);
- pBlockTable->close();
- AcDbObjectId objectId = AcDbObjectId::kNull;
- es = pBlockTableRecord->appendAcDbEntity(objectId, pEnt);
- objId = objectId;
- pBlockTableRecord->close();
- pEnt->close();
- return es;
- }
复制代码 |
|