天气与日历 切换到窄版

 找回密码
 立即注册
中国膜结构网
十大进口膜材评选 十大国产膜材评选 十大膜结构设计评选 十大膜结构公司评选
查看: 140|回复: 0

改变多段线区直 弧线

[复制链接]
  • TA的每日心情
    开心
    7 小时前
  • 签到天数: 20 天

    [LV.4]偶尔看看III

    115

    主题

    11

    回帖

    1393

    积分

    管理员

    积分
    1393
    QQ
    发表于 2024-5-4 18:41:04 | 显示全部楼层 |阅读模式
    1. 代码:
    2. #include "StdAfx.h"
    3. #include "StdArx.h"
    4. #include <dbpl.h>
    5. #include "..\..\Common\Others\ConvertUtil.h"
    6. #include <geassign.h>
    7. #include "..\..\Common\Entity\ArcUtil.h"
    8. #include "..\..\Common\Document\DwgDatabaseUtil.h"
    9. #include <afxwin.h>
    10. #include <dbents.h>
    11. void ZffMyProjectchangeline()
    12. {
    13. ads采用name polyLinename;
    14. ads采用point pnt;
    15. if (acedEntSel("\n请选择多段线的条直线段!",polyLinename,pnt)!=RTNORM)
    16. {
    17. return;
    18. }
    19. AcDbObjectId polyLineId;
    20. acdbGetObjectId(polyLineId,polyLinename);
    21. AcDbEntity *pEnt=NULL;
    22. acdbOpenObject(pEnt,polyLineId,AcDb::kForWrite);
    23. if (pEnt->isKindOf(AcDbPolyline::desc()))
    24. {
    25. AcDbPolyline *pPolyline=AcDbPolyline::cast(pEnt);
    26. pEnt->close();
    27. int vtnum=pPolyline->numVerts();
    28. AcGePoint3dArray pts;
    29. AcGePoint3d pt;
    30. for(int i=0; i<vtnum; i++)
    31. {
    32. pPolyline->getPointAt(i, pt);
    33. pts.append(pt);
    34. }
    35. AcDbVoidPtrArray curves;
    36. pPolyline->getSplitCurves(pts,curves);
    37. bool nRb=true;
    38. for (i=0;i<curves.length();i++)
    39. {
    40. AcDbCurve *pCurve=static采用cast<AcDbCurve*>(curves[i]);
    41. if (nRb)
    42. {
    43. AcGeLine2d geLine;
    44. AcGePoint3d pt1,pt2;
    45. pCurve->getStartPoint(pt1);
    46. pCurve->getEndPoint(pt2);
    47. AcGePoint2d pt12d,pt22d,pnt2d,pt2d;
    48. ads采用point pt;
    49. AcGePoint3d ptOnArc;
    50. pt12d=CConvertUtil::ToPoint2d(pt1);
    51. pt22d=CConvertUtil::ToPoint2d(pt2);
    52. pnt2d=CConvertUtil::ToPoint2d(asPnt3d(pnt));
    53. geLine.set(pt12d,pt22d);
    54. double tol =1;
    55. if (geLine.distanceTo(pnt2d)<tol)
    56. {
    57. nRb=false;
    58. delete pCurve;
    59. pCurve->close();
    60. acedGetPoint(NULL,"\n输入一个点:",pt);
    61. pt2d=CConvertUtil::ToPoint2d(asPnt3d(pt));
    62. AcGeCircArc2d geArc(pt12d, pt2d, pt22d);
    63. AcGePoint2d ptCenter = geArc.center();
    64. double radius = geArc.radius();
    65. AcGeVector2d vecStart(pt12d.x - ptCenter.x, pt12d.y - ptCenter.y);
    66. AcGeVector2d vecEnd(pt22d.x - ptCenter.x, pt22d.y - ptCenter.y);
    67. double startAngle = vecStart.angle();
    68. double endAngle = vecEnd.angle();
    69. AcDbArc *pArc=new AcDbArc(CConvertUtil::ToPoint3d(ptCenter), radius, startAngle, endAngle);
    70. pArc->getClosestPointTo(asPnt3d(pt),ptOnArc);
    71. if (CConvertUtil::ToPoint2d(ptOnArc).distanceTo(pt2d)<tol)
    72. {
    73. CDwgDatabaseUtil::PostToModelSpace(pArc);
    74. }
    75. else
    76. {
    77. AcDbArc *pArc2=new AcDbArc(CConvertUtil::ToPoint3d(ptCenter),radius,endAngle,startAngle);
    78. CDwgDatabaseUtil::PostToModelSpace(pArc2);
    79. delete pArc;
    80. }
    81. continue;
    82. }
    83. }
    84. CDwgDatabaseUtil::PostToModelSpace(pCurve);
    85. pCurve->close();
    86. }
    87. acdbOpenObject(pPolyline,polyLineId,AcDb::kForWrite);
    88. pPolyline->erase();
    89. pPolyline->close();
    90. }
    91. pEnt->close();
    92. }
    复制代码

     

     

     

     

    改变多段线区直 弧线
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|Archiver|中国膜结构网|中国膜结构协会|进口膜材|国产膜材|ETFE|PVDF|PTFE|设计|施工|安装|车棚|看台|污水池|中国膜结构网_中国空间膜结构协会

    GMT+8, 2024-11-5 12:30 , Processed in 0.142987 second(s), 29 queries .

    Powered by Discuz! X3.5

    © 2001-2024 Discuz! Team.

    快速回复 返回顶部 返回列表