admin 发表于 2024-5-4 18:45:39

ObjectARX 合并各种情况的圆弧


static void zffObjectARX_MyCommand18(void)
{
ads_name ss;
acedSSGet(NULL,NULL,NULL,NULL,ss);
long len;
acedSSLength(ss,&len);
double startAng,endAng;
double radius;
AcGePoint3d center;

for (int i=0;i<len;)
{
AcDbArc* pArc=NULL;
AcDbObjectId entId;
ads_name name,name1;
acedSSName(ss,i,name);
acdbGetObjectId(entId,name);
acdbOpenObject(pArc,entId,AcDb::kForWrite);
double arcStartAng=pArc->startAngle();
double arcEndAng=pArc->endAngle();
if (arcEndAng==0)
{
arcEndAng+=2*pi();
}
AcGePoint3d arcCenter=pArc->center();
double arcRadius=pArc->radius();
radius=arcRadius;
center=arcCenter;
startAng=arcStartAng;
endAng=arcEndAng;

for (int j=i+1;j<len;)
{
AcDbArc* pArc1=NULL;
acedSSName(ss,j,name1);
acdbGetObjectId(entId,name1);
acdbOpenObject(pArc1,entId,AcDb::kForWrite);
double arc1StartAng=pArc1->startAngle();
double arc1EndAng=pArc1->endAngle();
if (arc1EndAng==0)
{
arc1EndAng+=2*pi();
}
AcGePoint3d arc1Center=pArc1->center();
double arc1Radius=pArc1->radius();
if (arcCenter==arc1Center && arcRadius==arc1Radius)
{
if (arc1StartAng<startAng)
{
startAng=arc1StartAng;
}
if (arc1EndAng>endAng)
{
endAng=arc1EndAng;
}
acedSSDel(name1,ss);
pArc1->erase();
acedSSLength(ss,&len);
}
else
{
j++;
}
pArc1->close();
}
acedSSDel(name,ss);
pArc->erase();
pArc->close();
acedSSLength(ss,&len);
AcDbArc* pArcRe=new AcDbArc(center,radius,startAng,endAng);
AddToModelSpace(pArcRe);
}
}
页: [1]
查看完整版本: ObjectARX 合并各种情况的圆弧