Autodesk ObjectARX
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
curious problem about hatch display
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
I have two hatches, one is created from arx code, the other is drawed throuth cad's "hatch" command. both have the same scale property, but they display differently. look the picture below.
the code I use to insert the hatch is below:
AcDbObjectId DrawHatch(const AcDbObjectIdArray& loops,const TCHAR* szPattern,double dScale,const int nColorIndex,const double dElevation,const bool bAssociative,TCHAR *szCode,AcDbGroup *pGroup,TCHAR *szLayer,bool bCustom)
{
AcDbObjectId hatchID = AcDbObjectId::kNull;
AcDbHatch* pHatch = new AcDbHatch();
// Set hatch plane
AcGeVector3d normal(0.0, 0.0, 1.0);
pHatch->setNormal(normal);//目前先只支持平行于平面的Hatch。
pHatch->setElevation(dElevation);
// Set non associative hatch
pHatch->setAssociative(bAssociative);
// Set hatch pattern to SolidFill type
if (!bCustom)
{
pHatch->setPattern(AcDbHatch::kPreDefined, szPattern);//目前只运行预定义的类型。
}
else
{
if (pHatch->setPattern(AcDbHatch::kCustomDefined,szPa
{
acutPrintf(_T("\n填充样式名\"%s\"不存在,用样式\"angle\"代替生成。
pHatch->setPattern(AcDbHatch::kPreDefined, _T("angle"));
}
}
// Set hatch style to kNormal
pHatch->setHatchStyle(AcDbHatch::kNormal);
pHatch->setPatternScale(dScale);
int i=0;
for (i=0;i<loops.length();i++)
{
AcDbObjectIdArray idArr;
idArr.setPhysicalLength(1);
idArr.append(loops[i]);
pHatch->appendLoop(AcDbHatch::kDefault,idArr);/
}
pHatch->evaluateHatch();//这个函数用于计算
if(AppendEntity(pHatch,hatchID) == false)
{
delete pHatch;
return hatchID;
}
if (bAssociative)
{
// Get all associative source boundary object Ids for later use.
//
AcDbObjectIdArray dbObjIds;
pHatch->getAssocObjIds(dbObjIds);
// Post hatch entity to database
//
// Attach hatchId to all source boundary objects for notification.
//
AcDbEntity *pEnt;
int numObjs = dbObjIds.length();
Acad::ErrorStatus es;
for (int i = 0; i < numObjs; i++)
{
es = acdbOpenAcDbEntity(pEnt, dbObjIds[i], AcDb::kForWrite);
if (es == Acad::eOk)
{
pEnt->addPersistentReactor(hatchID);
pEnt->close();
}
}
}
pHatch->setColorIndex(nColorIndex);
pHatch->close();
return hatchID;
}
and there is also an dwg attaced. you can check the two hatches , I found they have the same properties,but look differently.
Solved! Go to Solution.
Re: curious problem about hatch display
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
Try setting your pattern scale before you set the pattern.
Owen Wengerd
ManuSoft
Re: curious problem about hatch display
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
it works, and this imply that arx's design structure is somehow ,not clear, or uneasy to developers to understand.
anyway, thanks a lot
