高分求助填充问题
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, "SOLID");
// pHatch->setStyle(AcDbHatch::kNormal);
AcGePoint3d start022(120,100,0);
AcGePoint3d end022(180,100,0);
AcDbLine*a1Line=new AcDbLine(start022,end022);
//水沟右深度
AcGePoint3d start032(180,100,0);
AcGePoint3d end032(180,160,0);
AcDbLine*b1Line=new AcDbLine(start032,end032);
//水沟下宽度
AcGePoint3d start042(180,160,0);
AcGePoint3d end042(120,160,0);
AcDbLine*c1Line=new AcDbLine(start042,end042);
//水沟左直边
AcGePoint3d start052(120,160,0);
AcGePoint3d end052(120,100,0);
AcDbLine*d1Line=new AcDbLine(start052,end052);
postToModel(a1Line);
postToModel(b1Line);
postToModel(c1Line);
postToModel(d1Line);
a1Line->close();
b1Line->close();
c1Line->close();
d1Line->close();
AcDbObjectIdArray objIds;
//objIds.append(idpSemiCircle);
//objIds.append(idp1SemiCircle);
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
postToModel(pHatch);
pHatch->close();
没有错误,但是不能实现填充,不知错在哪里,请指教,谢谢!
稍微改了一下代码,没发现什么太大的错误。
我测试了一下,可以实现填充。
由于没有办法发图片,所以就不给你截图了。 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;
} 用list命令查看了一下实体信息,以此证明我绘制出来了。LIST 找到 1 个
HATCH 图层: 0
空间: 模型空间
句柄 = 2b6
填充图案 SOLID
非关联
面积 3600.0000
原点 X= 0.0000Y= 0.0000Z= 0.0000 谢谢解答,但是在我这里不能运行,有错误 把下面这句代码,写到最上面Acad::ErrorStatus postToModel(AcDbObjectId& objId, AcDbEntity* pEnt);
回复 th_gsb 的帖子
谢谢!!! 晕,开了这么多贴。。。
页:
[1]