- 积分
- 343
- 明经币
- 个
- 注册时间
- 2007-10-9
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
Acad::ErrorStatus postToModel(AcDbObjectId& objId, AcDbEntity* pEnt);
// 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::kTrue);
pHatch->setPattern(AcDbHatch::kPreDefined, _T("SOLID"));
// pHatch->setStyle(AcDbHatch::kNormal);
int a=1000;int b=1000;
//左墙高
AcGePoint3d start1(a,b,0);
AcGePoint3d end1(a,b+(m_fHight_L_HD),0);
AcDbLine*q2Line=new AcDbLine(start1,end1);
AcDbObjectId idq2Line = AcDbObjectId::kNull;
postToModel(idq2Line,q2Line);
//右墙高
AcGePoint3d start2(a+(m_fWidth_HD),b,0);
AcGePoint3d end2(a+(m_fWidth_HD),b+(m_fHight_R_HD),0);
AcDbLine*r2Line=new AcDbLine(start2,end2);
AcDbObjectId idr2Line = AcDbObjectId::kNull;
postToModel(idr2Line,r2Line);
int m_thinckness=100;
//左高
AcGePoint3d start21(a+m_thinckness,b,0);
AcGePoint3d end21(a+m_thinckness,b+m_fHight_L_HD,0);
AcDbLine*qLine=new AcDbLine(start21,end21);
AcDbObjectId idqLine = AcDbObjectId::kNull;
postToModel(idqLine,qLine);
//右高
AcGePoint3d start22(a+m_fWidth_HD-m_thinckness,b,0);
AcGePoint3d end22(a+m_fWidth_HD-m_thinckness,b+(m_fHight_R_HD),0);
AcDbLine*rLine=new AcDbLine(start22,end22);
AcDbObjectId idrLine = AcDbObjectId::kNull;
postToModel(idrLine,rLine);
///////////////////////////////
//半圆拱底部连线1
AcGePoint3d start8(a,b+m_fHight_L_HD,0);
AcGePoint3d end8(a+m_thinckness,b+m_fHight_L_HD,0);
AcDbLine*dLine=new AcDbLine(start8,end8);
AcDbObjectId iddLine = AcDbObjectId::kNull;
postToModel(iddLine,dLine);
//半圆拱底部连线2
AcGePoint3d start9(a+m_fWidth_HD-m_thinckness,b+m_fHight_R_HD,0);
AcGePoint3d end9(a+m_fWidth_HD,b+(m_fHight_R_HD),0);
AcDbLine*cLine=new AcDbLine(start9,end9);
AcDbObjectId idcLine = AcDbObjectId::kNull;
postToModel(idcLine,cLine);
/////////////////////////////////////
//半圆拱外圆
AcDbArc*pSemiCircle=new AcDbArc(AcGePoint3d ((a+(m_fWidth_HD)/2), (b+(m_fHight_L_HD)/2+(m_fHight_R_HD)/2), 0), (m_fWidth_HD)/2, 0, PI );
AcDbObjectId idpSemiCircle = AcDbObjectId::kNull;
postToModel(idpSemiCircle,pSemiCircle);
//半圆拱内圆
AcDbArc*p1SemiCircle=new AcDbArc(AcGePoint3d ((a+(m_fWidth_HD)/2), b+(m_fHight_L_HD)/2+(m_fHight_R_HD)/2, 0),
(m_fWidth_HD-m_thinckness*2)/2, 0, PI );
AcDbObjectId idp1SemiCircle = AcDbObjectId::kNull;
postToModel(idp1SemiCircle,p1SemiCircle);
//直墙厚度左连线
AcGePoint3d start23(a,b,0);
AcGePoint3d end23(a+m_thinckness,b,0);
AcDbLine*q1Line=new AcDbLine(start23,end23);
AcDbObjectId idq1Line = AcDbObjectId::kNull;
postToModel(idq1Line,q1Line);
//直墙厚度右连线
AcGePoint3d start24(a+m_fWidth_HD-m_thinckness,b,0);
AcGePoint3d end24(a+m_fWidth_HD,b,0);
AcDbLine*r1Line=new AcDbLine(start24,end24);
AcDbObjectId idr1Line = AcDbObjectId::kNull;
postToModel(idr1Line,r1Line);
AcDbObjectIdArray objIds;
objIds.append(idq2Line);
objIds.append(idr2Line);
objIds.append(idqLine);
objIds.append(idrLine);
objIds.append(idq1Line);
objIds.append(idr1Line);
objIds.append(iddLine);
objIds.append(idcLine);
objIds.append(idpSemiCircle);
objIds.append(idp1SemiCircle);
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;
}
找好心人帮助,解决了部分问题,图形绘出了,但是没有填充效果,就是没有填上,不知为何?
|
|