|
static void MyGroupMyCommand4()
{
Acad::ErrorStatus es;
Adesk::Int32 LoopType;
AcGeVoidPointerArray edgeptrAry;
AcGeIntArray edgeTypesAry;
AcGePoint2dArray vertices;
AcGeDoubleArray bulges;
ads_point pt;
ads_name en;
if(acedEntSel(_T("\n选择填充图案:"), en, pt) != RTNORM) return;
AcDbObjectId Id;
acdbGetObjectId(Id, en);
AcDbEntity *pEnt = NULL;
acdbOpenObject(pEnt, Id, AcDb::kForRead);
AcDbHatch *pHatch = AcDbHatch::cast(pEnt);
if(pHatch == NULL)
{
pEnt->close();
return;
}
//获得填充边界的数目
int LoopNum = pHatch->numLoops();
for (int i=0; i<LoopNum; i++)
{
//获取边界类型
LoopType = pHatch->loopTypeAt(i);
//如果边界是多义线
if (LoopType & AcDbHatch::kPolyline)
{
//取得边界定义数据(polyline)的顶点数组和凸度数组,它们是一一对应的
es = pHatch->getLoopAt(i, LoopType, vertices, bulges);
//acutPrintf("\n多义线");
//是不是根据这些顶点数组和凸度数组构造一条AcDb多义线取决于你
}
else
{
//几乎可以取得除polyline外的所有边界定义数据
//第三个参数返回值是无值指针数组
//第四个参数返回值是组成边界的每一条边的类型
//它们也是一一对应的关系
es = pHatch->getLoopAt(i, LoopType, edgeptrAry, edgeTypesAry);
//遍历,因为每一条边界又可能由多种AcGe曲线构成
for (int j=0; j<edgeTypesAry.length(); j++)
{
if(edgeTypesAry[j]==AcDbHatch::kLine)//直线
{
AcGeLineSeg2d *LnSeg=(AcGeLineSeg2d *)edgeptrAry;
//acutPrintf("\n直线");
}
else if(edgeTypesAry[j]==AcDbHatch::kCirArc)//圆弧
{
AcGeCircArc2d *CirArc=(AcGeCircArc2d *)edgeptrAry;
//acutPrintf("\n圆弧");
//可以根据数学圆弧构造相应的AcDb圆弧,取决于你(以下同)
}
else if(edgeTypesAry[j]==AcDbHatch::kEllArc)//椭圆弧
{
AcGeEllipArc2d *EllArc=(AcGeEllipArc2d *)edgeptrAry;
//acutPrintf("\n椭圆弧");
}
else if(edgeTypesAry[j]==AcDbHatch::kSpline)//NURBS曲线
{
AcGeNurbCurve2d *Spline=(AcGeNurbCurve2d *)edgeptrAry;
//acutPrintf("\nNURBS曲线");
}
}
}
}
pEnt->close();
} |
|