关于AcDbHatch的问题?
我是一个初学者,请各位帮我看一下,下面是画一个园,然后填充,程序编译通过,但运行时没有填充出来。void test()<BR>{<BR> ads_point pt1;<BR> <BR> if(ads_getpoint(NULL,"\n请输入插入点:",pt1)!=RTNORM) return;<BR>
AcGePoint3d basePoint(pt1,pt1,pt1);<BR> AcDbCircle *pCircle=new AcDbCircle;<BR> pCircle->setCenter(basePoint);<BR> pCircle->setRadius(1.5);<BR> pCircle->setColorIndex(1);
AcDbHatch* pHatch = new AcDbHatch();<BR> AcGeVector3d normal(0.0, 0.0, 1.0);<BR> pHatch->setNormal(normal);<BR> pHatch->setElevation(0.0);<BR> pHatch->setAssociative(Adesk::kTrue);<BR> pHatch->setPattern(AcDbHatch::kPreDefined, "SOLID");<BR> pHatch->setHatchStyle(AcDbHatch::kNormal);
<BR> <BR> AcDbBlockTable *pBlockTable;<BR> acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pBlockTable,AcDb::kForRead);<BR> AcDbBlockTableRecord *pBlockTableRecord;<BR> pBlockTable->getAt(ACDB_MODEL_SPACE,pBlockTableRecord,AcDb::kForWrite);<BR> pBlockTable->close();<BR> <BR> AcDbObjectId circleId;<BR> AcDbObjectId hatchId;
AcDbObjectIdArray dbObjIds;
<BR> pBlockTableRecord->appendAcDbEntity(circleId,pCircle);<BR> dbObjIds.setLogicalLength(0);<BR> dbObjIds.append(circleId); <BR> <BR> pHatch->appendLoop(AcDbHatch::kDefault, dbObjIds);<BR> pHatch->evaluateHatch();
dbObjIds.setLogicalLength(0);<BR> pHatch->getAssocObjIds(dbObjIds);<BR> pBlockTableRecord->appendAcDbEntity(hatchId,pHatch);
pBlockTableRecord->close();
<BR> <BR> AcDbEntity *pEnt;<BR> int numObjs = dbObjIds.length();<BR> Acad::ErrorStatus es;<BR> int i;<BR> for (i = 0; i < numObjs; i++) {<BR> es = acdbOpenAcDbEntity(pEnt, dbObjIds, AcDb::kForWrite);<BR> if (es == Acad::eOk) {<BR> pEnt->addPersistentReactor(hatchId);<BR> pEnt->close();<BR> }<BR> }
<BR> <BR> pCircle->close();<BR> pHatch->close();
} 最好用範圍來畫.
AcDbHatch* pHatch = new AcDbHatch();<BR> AcGeVector3d normal(0.0, 0.0, 1.0);<BR> pHatch->setNormal(normal);<BR> pHatch->setElevation(0.0);<BR> pHatch->setAssociative(Adesk::kFalse);<BR> <BR> pHatch->setHatchStyle(AcDbHatch::kNormal);<BR> pHatch->setPatternScale(10.0);<BR> AcGePoint2dArray vertexPts;<BR> AcGeDoubleArray vertexBulges;<BR> vertexPts.setPhysicalLength(0).setLogicalLength(4);<BR> vertexPts.set(m_d/2,0);<BR> vertexPts.set(0,m_d/2);<BR> vertexPts.set(0,0);<BR> vertexPts.set(m_d/2,0);<BR> vertexBulges.setPhysicalLength(0).setLogicalLength(4);<BR> vertexBulges = 0.414;<BR> vertexBulges = 0;<BR> vertexBulges = 0;<BR> vertexBulges = 0;<BR> color.setColorIndex(150);<BR> pHatch->setColor(color);<BR> pHatch->appendLoop(AcDbHatch::kExternal, vertexPts, vertexBulges);<BR> pHatch->setPattern(AcDbHatch::kUserDefined, "SOLID");
代替你畫的部分<BR>
关于AcDbHatch的问题?
非常感谢chang,但是我试了你提供的代码仍然没有填充出来,希望给出一段画一个园,并用solid填充的完整代码。 要想用其他的颜色填充怎么实现啊? 补充pHatch->updateOpen()在close()之前; 本帖最后由 作者 于 2004-8-7 17:24:12 编辑你的方法是hatch关联园的ID,但是园没有加到模型空间。也就是说没有ID.当然出现不了hatch。且要加到模型空间
你将我的hatch加到模型空间,就好了。
页:
[1]