天气与日历 切换到窄版

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

多段线动态切割闭合区域

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

    [LV.4]偶尔看看III

    115

    主题

    11

    回帖

    1393

    积分

    管理员

    积分
    1393
    QQ
    发表于 2024-5-4 18:39:42 | 显示全部楼层 |阅读模式


    1. #include "StdAfx.h"
    2. #include "StdArx.h"
    3. #include <dbpl.h>
    4. #include "..\..\Common\Others\ConvertUtil.h"
    5. #include "..\..\Common\Document\DwgDatabaseUtil.h"
    6. #include <dbents.h>
    7. #include <dbregion.h>
    8. #include "..\..\Common\Entity\RegionUtil.h"

    9. // This is command 'INTERSECT1'
    10. void ZffMyProjectintersect1()
    11. {
    12. // TODO: Implement the command
    13. ads采用name polyLinename;
    14. ads采用name polyLinename2;
    15. ads采用point pnt;
    16. ads采用point pnt2;

    17. AcDbPolyline *pPolyline=NULL;
    18. AcDbPolyline *pPoly=NULL;
    19. AcDbRegion *pRegion1=NULL;
    20. AcDbRegion *pRegion2=NULL;
    21. acedEntSel("\n请选择截取多段线!",polyLinename,pnt);
    22. AcDbObjectId polyLineId;
    23. acdbGetObjectId(polyLineId,polyLinename);
    24. AcDbEntity *pEnt=NULL;
    25. AcGePoint3dArray pts,pts2;
    26. acdbOpenObject(pEnt,polyLineId,AcDb::kForWrite);

    27. if (pEnt->isKindOf(AcDbPolyline::desc()))
    28. {
    29. pPolyline=AcDbPolyline::cast(pEnt);
    30. pEnt->close();
    31. }
    32. AcDbVoidPtrArray curves;
    33. int num=pPolyline->numVerts();
    34. for (int i=0;i<num;i++)
    35. {
    36. AcGePoint2d pt;
    37. pPolyline->getPointAt(i,pt);
    38. pts.append(CConvertUtil::ToPoint3d(pt));
    39. }
    40. pPolyline->getSplitCurves(pts,curves);
    41. pPolyline->close();
    42. AcDbObjectIdArray curvesId;
    43. AcDbCurve *pCurve=NULL;
    44. for (i=0;i<curves.length();i++)
    45. {
    46. pCurve=static采用cast<AcDbCurve*>(curves[i]);
    47. curvesId.append(CDwgDatabaseUtil::PostToModelSpace(pCurve));
    48. }
    49. pCurve->close();

    50. acedEntSel("\n请选择被截取多段线!",polyLinename2,pnt2);
    51. acdbGetObjectId(polyLineId,polyLinename2);
    52. acdbOpenObject(pEnt,polyLineId,AcDb::kForWrite);
    53. if (pEnt->isKindOf(AcDbPolyline::desc()))
    54. {
    55. pPoly=AcDbPolyline::cast(pEnt);
    56. pEnt->close();
    57. //pPoly->intersectWith(pPolyline,AcDb::kOnBothOperands,pts,0,0);
    58. }
    59. AcDbVoidPtrArray curves2;
    60. num=pPoly->numVerts();
    61. for (i=0;i<num;i++)
    62. {
    63. AcGePoint2d pt2;
    64. pPoly->getPointAt(i,pt2);
    65. pts2.append(CConvertUtil::ToPoint3d(pt2));
    66. }
    67. pPoly->getSplitCurves(pts2,curves2);
    68. pPoly->close();
    69. AcDbObjectIdArray curvesId2;
    70. AcDbCurve *pCurve2=NULL;
    71. for (i=0;i<curves2.length();i++)
    72. {
    73. pCurve2=static采用cast<AcDbCurve*>(curves2[i]);
    74. curvesId2.append(CDwgDatabaseUtil::PostToModelSpace(pCurve2));
    75. }
    76. pCurve2->close();
    77. AcDbObjectIdArray regId=CRegionUtil::Add(curvesId);
    78. AcDbObjectIdArray regId2=CRegionUtil::Add(curvesId2);
    79. for (i=0;i<curvesId.length();i++)
    80. {
    81. acdbOpenObject(pCurve,curvesId[i],AcDb::kForWrite);
    82. pCurve->erase();
    83. pCurve->close();
    84. }
    85. for (i=0;i<curvesId2.length();i++)
    86. {
    87. acdbOpenObject(pCurve2,curvesId2[i],AcDb::kForWrite);
    88. pCurve2->erase();
    89. pCurve2->close();
    90. }
    91. acdbOpenObject(pRegion1,regId[0],AcDb::kForWrite);
    92. acdbOpenObject(pRegion2,regId2[0],AcDb::kForWrite);
    93. pRegion1->booleanOper(AcDb::kBoolIntersect,pRegion2);
    94. pRegion1->close();
    95. pRegion2->close();
    96. }
    复制代码

     

     

     

     

    多段线动态切割闭合区域
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

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

    GMT+8, 2024-11-5 12:28 , Processed in 0.166552 second(s), 27 queries .

    Powered by Discuz! X3.5

    © 2001-2024 Discuz! Team.

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