- UID
- 770541
- 积分
- 410
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2017-8-19
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
本帖最后由 1121443108qaz 于 2018-7-13 10:55 编辑
如图,第一行是没做变更的,第二行是我用模仿的命令变更的,第三行是用PE,米,J得到的,第三行是我要的效果。公差是0.0005,文件已经上传了。想知道怎样才能得到第三行那样的效果,也就是延伸那样的效果。
- static void xxxMyGroupjoin()
- {
- ads_name ss;
- TCHAR keyword[20];
- int rc = CSSUtil::GetSS(ss, keyword);
- if (rc != RTNORM)
- {
- return;
- }
- AcDbObjectIdArray entIds = CSSUtil::GetSsEntIds(ss);
- acedInitGet(RSG_NONEG, NULL);
- ads_real tolrence;
- rc = acedGetReal(L"\n请输入忽略距离<0.0005>:", &tolrence);
- switch (rc)
- {
- case RTERROR:
- return;
- case RTCAN:
- return;
- case RTNONE:
- tolrence = 0.0005;
- }
- bool isAllCurves = MyUtil::join(entIds, tolrence);
- if (isAllCurves != true)
- {
- acutPrintf(L"\n存在本程序处理不了的实体!");
- }
- acedSSFree(ss);
- }
- bool MyUtil::topl(AcDbObjectIdArray& entIds, double tol /* = 0.0005 */)
- {
- AcGeTol geTol;
- geTol.setEqualPoint(tol);
- bool isAllcurve = true;
- AcArray<AcDbEntity*> pEnts;
- AcDbEntity*pEnt = NULL;
- int len = entIds.length();
- for (int i = 0; i < len; i++)
- {
- acdbOpenObject(pEnt, entIds.at(i), AcDb::kForWrite);
- pEnts.append(pEnt);
- }
- AcGeIntArray indexes;
-
- while (pEnts.length() != 0)
- {
- AcDbPolyline* pPoly = NULL;
- pEnt = pEnts[0];
- pEnts = pEnts.removeFirst();
- AcGePoint2d pt1, pt2;
- if (!pEnt->isKindOf(AcDbLine::desc()) && !pEnt->isKindOf(AcDbPolyline::desc()) && !pEnt->isKindOf(AcDbArc::desc()))
- {
- pEnt->close();
- isAllcurve = false;
- continue;
- }
- else if (pEnt->isKindOf(AcDbLine::desc()))
- {
- AcDbLine* pLine = AcDbLine::cast(pEnt);
- pt1 = CConvertUtil::ToPoint2d(pLine->startPoint());
- pt2 = CConvertUtil::ToPoint2d(pLine->endPoint());
- pPoly = new AcDbPolyline(2);
- pPoly->addVertexAt(0, pt1);
- pPoly->addVertexAt(1, pt2);
- }
- else if (pEnt->isKindOf(AcDbArc::desc()))
- {
- AcDbArc* pArc = AcDbArc::cast(pEnt);
- double angleStart, angleEnd,radius;
- AcGePoint2d ptCenter=CConvertUtil::ToPoint2d(pArc->center());
- radius = pArc->radius();
- angleStart = pArc->startAngle();
- angleEnd = pArc->endAngle();
- AcGePoint2d pt1, pt2;
- pt1.x = ptCenter.x + radius * cos(angleStart);
- pt1.y = ptCenter.y + radius * sin(angleStart);
- pt2.x = ptCenter.x + radius * cos(angleEnd);
- pt2.y = ptCenter.y + radius * sin(angleEnd);
- pPoly = new AcDbPolyline(3);
- pPoly->addVertexAt(0, pt1, angleStart, 0, 0);
- pPoly->addVertexAt(1, pt2, angleEnd, 0, 0);
- }
- else
- {
- pPoly = AcDbPolyline::cast(pEnt->clone());
- if (pPoly->isClosed())
- {
- pPoly->close();
- pEnt->close();
- continue;
- }
- }
- AcDbJoinEntityPE* pJoin = AcDbJoinEntityPE::cast(pPoly->queryX(AcDbJoinEntityPE::desc()));
- ErrorStatus es = pJoin->joinEntities(pPoly, pEnts, indexes,geTol);
- if (es == Acad::eOk)
- {
- for (int j = 0; j < pEnts.length(); j++)
- {
- AcDbEntity* pEnt2 = pEnts.at(j);
- if (indexes.contains(j))
- {
- pEnt2->erase();
- pEnt2->close();
- pEnts = pEnts.removeAt(j);
- for (int k = 0; k < indexes.length(); k++)
- {
- indexes.at(k) = indexes.at(k) - 1;
- }
- j = j - 1;
- }
- }
- CDwgDatabaseUtil::postToMOdelSpace(pPoly);
- pEnt->erase();
- }
- else
- {
- pPoly->close();
- }
- pEnt->close();
- indexes = indexes.removeAll();
- }
- return isAllcurve;
- }
|
|