明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2409|回复: 5

关于AcDbHatch的问题?

[复制链接]
发表于 2004-5-14 18:06:00 | 显示全部楼层 |阅读模式
我是一个初学者,请各位帮我看一下,下面是画一个园,然后填充,程序编译通过,但运行时没有填充出来。 void test()
{
ads_point pt1;

if(ads_getpoint(NULL,"\n请输入插入点:",pt1)!=RTNORM) return;
AcGePoint3d basePoint(pt1[0],pt1[1],pt1[2]);
AcDbCircle *pCircle=new AcDbCircle;
pCircle->setCenter(basePoint);
pCircle->setRadius(1.5);
pCircle->setColorIndex(1); 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, "SOLID");
pHatch->setHatchStyle(AcDbHatch::kNormal);

AcDbBlockTable *pBlockTable;
acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pBlockTable,AcDb::kForRead);
AcDbBlockTableRecord *pBlockTableRecord;
pBlockTable->getAt(ACDB_MODEL_SPACE,pBlockTableRecord,AcDb::kForWrite);
pBlockTable->close();

AcDbObjectId circleId;
AcDbObjectId hatchId; AcDbObjectIdArray dbObjIds;
pBlockTableRecord->appendAcDbEntity(circleId,pCircle);
dbObjIds.setLogicalLength(0);
dbObjIds.append(circleId);

pHatch->appendLoop(AcDbHatch::kDefault, dbObjIds);
pHatch->evaluateHatch(); dbObjIds.setLogicalLength(0);
pHatch->getAssocObjIds(dbObjIds);
pBlockTableRecord->appendAcDbEntity(hatchId,pHatch); pBlockTableRecord->close();

AcDbEntity *pEnt;
int numObjs = dbObjIds.length();
Acad::ErrorStatus es;
int i;
for (i = 0; i < numObjs; i++) {
es = acdbOpenAcDbEntity(pEnt, dbObjIds, AcDb::kForWrite);
if (es == Acad::eOk) {
pEnt->addPersistentReactor(hatchId);
pEnt->close();
}
}

pCircle->close();
pHatch->close(); }
发表于 2004-5-15 15:13:00 | 显示全部楼层
最好用範圍來畫. AcDbHatch* pHatch = new AcDbHatch();
AcGeVector3d normal(0.0, 0.0, 1.0);
pHatch->setNormal(normal);
pHatch->setElevation(0.0);
pHatch->setAssociative(Adesk::kFalse);

pHatch->setHatchStyle(AcDbHatch::kNormal);
pHatch->setPatternScale(10.0);
AcGePoint2dArray vertexPts;
AcGeDoubleArray vertexBulges;
vertexPts.setPhysicalLength(0).setLogicalLength(4);
vertexPts[0].set(m_d/2,0);
vertexPts[1].set(0,m_d/2);
vertexPts[2].set(0,0);
vertexPts[3].set(m_d/2,0);
vertexBulges.setPhysicalLength(0).setLogicalLength(4);
vertexBulges[0] = 0.414;
vertexBulges[1] = 0;
vertexBulges[2] = 0;
vertexBulges[3] = 0;
color.setColorIndex(150);
pHatch->setColor(color);
pHatch->appendLoop(AcDbHatch::kExternal, vertexPts, vertexBulges);
pHatch->setPattern(AcDbHatch::kUserDefined, "SOLID"); 代替你畫的部分
 楼主| 发表于 2004-5-16 10:12:00 | 显示全部楼层

关于AcDbHatch的问题?

非常感谢chang,但是我试了你提供的代码仍然没有填充出来,希望给出一段画一个园,并用solid填充的完整代码。
发表于 2004-5-18 09:36:00 | 显示全部楼层
要想用其他的颜色填充怎么实现啊?
发表于 2004-7-14 21:04:00 | 显示全部楼层
补充pHatch-&gt;updateOpen()在close()之前;
发表于 2004-8-7 16:58:00 | 显示全部楼层
本帖最后由 作者 于 2004-8-7 17:24:12 编辑

你的方法是hatch关联园的ID,但是园没有加到模型空间。也就是说没有ID.当然出现不了hatch。且要加到模型空间



你将我的hatch加到模型空间,就好了。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-26 06:46 , Processed in 0.166213 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表