天气与日历 切换到窄版

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

JoinToPline 连接线段成多段线

  [复制链接]
  • TA的每日心情
    开心
    昨天 06:36
  • 签到天数: 15 天

    [LV.4]偶尔看看III

    105

    主题

    11

    回帖

    1308

    积分

    管理员

    积分
    1308
    QQ
    发表于 2024-2-15 16:33:55 | 显示全部楼层 |阅读模式
    1. //-----------------------------------------------------------------------------
    2. //----- acrxEntryPoint.cpp
    3. //-----------------------------------------------------------------------------
    4. #include "StdAfx.h"
    5. #include "resource.h"
    6. //-----------------------------------------------------------------------------
    7. #define szRDS 采用RXST("")
    8. //-----------------------------------------------------------------------------
    9. //----- ObjectARX EntryPoint
    10. class CJoinToPlineApp : public AcRxArxApp {
    11. public:
    12.   CJoinToPlineApp () : AcRxArxApp () {}
    13.   virtual AcRx::AppRetCode On采用kInitAppMsg (void *pkt) {
    14.     AcRx::AppRetCode retCode = AcRxArxApp::On采用kInitAppMsg (pkt) ;
    15.     return (retCode) ;
    16.   }
    17.   virtual AcRx::AppRetCode On采用kUnloadAppMsg (void *pkt) {
    18.     AcRx::AppRetCode retCode = AcRxArxApp::On采用kUnloadAppMsg (pkt) ;
    19.     return (retCode) ;
    20.   }
    21.   virtual void RegisterServerComponents () {
    22.   }
    23.   static void JoinToPlineJoinToPline () {
    24.     // Фильтр для выбора отрезков (LINE) и дуг (ARC)
    25.     ACHAR* promptPtrs[] = {
    26.       采用T("\nSelect lines and arcs for join in poyline (ENTER - exit): "),
    27.       采用T("\nRemove lines and arcs from selection set: ")
    28.     };
    29.     ads采用name ss;
    30.     resbuf *rbFilter = acutBuildList(RTDXF0,采用T("LINE,ARC"),RTNONE);
    31.     int rc = acedSSGet(采用T(":$"),promptPtrs,NULL,rbFilter,ss);
    32.     acutRelRb(rbFilter);
    33.     if (rc != RTNORM) return;
    34.     AcDbObjectIdArray ids;
    35.     if (ObjectIdArrayFromSelSet(ss, ids) != Acad::eOk) return;
    36.     while (ids.length() > 0)
    37.     {
    38.       AcDbEntity *p = MakeJonedPoly(ids);
    39.       if (p) {
    40.         AcDbBlockTableRecordPointer pSpace(acdbCurDwg()->currentSpaceId(), AcDb::kForWrite);
    41.         if (pSpace.openStatus() != Acad::eOk) return;
    42.         pSpace->appendAcDbEntity(p);
    43.         p->close();
    44.       } else {
    45.         acutPrintf(采用T("\nError in data!"));
    46.         return;
    47.       }
    48.     }
    49.   }
    50.   /// <summary>
    51.   /// AcDbObjectIdArray from SelectionSet
    52.   /// </summary>
    53.   /// <param name="sset">SelectionSet</param>
    54.   /// <param name="ids">AcDbObjectIdArray</param>
    55.   /// <returns></returns>
    56.   static Acad::ErrorStatus ObjectIdArrayFromSelSet(ads采用name sset, AcDbObjectIdArray &ids)
    57.   {
    58.     Acad::ErrorStatus es = Acad::eOk;
    59.     long nset = -1;
    60.     if (acedSSLength(sset,&nset) != RTNORM) return Acad::eAmbiguousInput;
    61.     ids.setLogicalLength(nset);
    62.     ads采用name en;
    63.     AcDbObjectId id;
    64.     for (long i=0; i < nset; i++) {
    65.       if (acedSSName(sset,i,en) == RTNORM) {
    66.         if ((es = acdbGetObjectId(id,en)) != Acad::eOk) return es;
    67.         ids[i] = id;
    68.       }
    69.     }
    70.     return Acad::eOk;
    71.   }
    72.   /// <summary>
    73.   /// Create polyline from lines and arcs.
    74.   /// Those ids will remove from input array
    75.   /// </summary>
    76.   /// <param name="ids">Array of id's</param>
    77.   /// <param name="FUZZ">The accuracy of determining the distance between points</param>
    78.   /// <returns></returns>
    79.   static AcDbPolyline* MakeJonedPoly(
    80.     AcDbObjectIdArray &ids,
    81.     double FUZZ = AcGeContext::gTol.equalPoint())
    82.   {
    83.     AcDbPolyline *p = new AcDbPolyline();
    84.     p->setDatabaseDefaults();
    85.     AcDbObjectId idFirst = ids[0];
    86.     AcGePoint3d nextPt = AcGePoint3d::kOrigin;
    87.     AcGePoint3d prevPt = AcGePoint3d::kOrigin;
    88.     AcDbObjectPointer<AcDbCurve> c(idFirst,AcDb::kForRead);
    89.     if (c.openStatus() == Acad::eOk) {
    90.       AcGePoint3d ptStart, ptEnd;
    91.       c->getStartPoint(ptStart); c->getEndPoint(ptEnd);
    92.       p->addVertexAt(0, asPnt2d(asDblArray(ptStart)), BulgeFromArc(c, false), 0, 0);
    93.       p->addVertexAt(1, asPnt2d(asDblArray(ptEnd)), 0, 0, 0);
    94.       nextPt = ptEnd;
    95.       prevPt = ptStart;
    96.     }
    97.     ids.remove(idFirst);
    98.     int prevCnt = ids.length() + 1;
    99.     while (ids.length() > 0 && ids.length() < prevCnt)
    100.     {
    101.       prevCnt = ids.length();
    102.       for (int i = 0; i < ids.length(); i++) {
    103.         AcDbObjectId id = ids[i];
    104.         AcDbObjectPointer<AcDbCurve> cv(id,AcDb::kForRead);
    105.         if (cv.openStatus() == Acad::eOk) {
    106.           AcGePoint3d ptStart, ptEnd;
    107.           cv->getStartPoint(ptStart); cv->getEndPoint(ptEnd);
    108.           if (ptStart.distanceTo(nextPt) < FUZZ || ptEnd.distanceTo(nextPt) < FUZZ) {
    109.             double bulge = BulgeFromArc(cv, ptEnd.distanceTo(nextPt) < FUZZ);
    110.             p->setBulgeAt(p->numVerts() - 1, bulge);
    111.             if (ptStart.distanceTo(nextPt) < FUZZ)
    112.               nextPt = ptEnd;
    113.             else
    114.               nextPt = ptStart;
    115.             p->addVertexAt(p->numVerts(), asPnt2d(asDblArray(nextPt)), 0, 0, 0);
    116.             ids.remove(id);
    117.             break;
    118.           } else if (ptStart.distanceTo(prevPt) < FUZZ || ptEnd.distanceTo(prevPt) < FUZZ) {
    119.             double bulge = BulgeFromArc(cv, ptStart.distanceTo(prevPt) < FUZZ);
    120.             if (ptStart.distanceTo(prevPt) < FUZZ)
    121.               prevPt = ptEnd;
    122.             else
    123.               prevPt = ptStart;
    124.             p->addVertexAt(0, asPnt2d(asDblArray(prevPt)), bulge, 0, 0);
    125.             ids.remove(id);
    126.             break;
    127.           }
    128.         }
    129.       }
    130.     }
    131.     if (p->numVerts() == 0) {
    132.       delete p;  return NULL;
    133.     }  else  {
    134.       return p;
    135.     }
    136.   }
    137.   /// <summary>
    138.   /// Getting bulge of curve
    139.   /// </summary>
    140.   /// <param name="c">AcDbCurve pointer</param>
    141.   /// <param name="clockwise">direction.</param>
    142.   /// <returns></returns>
    143.   static double BulgeFromArc(AcDbCurve *c, bool clockwise)
    144.   {
    145.     double bulge = 0.0;
    146.     AcDbArc *a = AcDbArc::cast(c);
    147.     if (a == NULL) return bulge;
    148.     double newStart =
    149.       (a->startAngle() > a->endAngle()) ?
    150.       (a->startAngle() - 8 * atan(1.0)) :
    151.       (a->startAngle());
    152.     bulge = tan((a->endAngle() - newStart) / 4.0);
    153.     if (clockwise) bulge = -bulge;
    154.     return bulge;
    155.   }
    156. } ;
    157. //-----------------------------------------------------------------------------
    158. IMPLEMENT采用ARX采用ENTRYPOINT(CJoinToPlineApp)
    159. ACED采用ARXCOMMAND采用ENTRY采用AUTO(CJoinToPlineApp, JoinToPline, JoinToPline, JoinToPline, ACRX采用CMD采用MODAL, NULL)
    复制代码

     

     

     

     

    JoinToPline 连接线段成多段线
  • TA的每日心情
    开心
    昨天 06:36
  • 签到天数: 15 天

    [LV.4]偶尔看看III

    105

    主题

    11

    回帖

    1308

    积分

    管理员

    积分
    1308
    QQ
     楼主| 发表于 2024-2-15 16:35:15 | 显示全部楼层
    1. //-----------------------------------------------------------------------------
    2. //----- acrxEntryPoint.cpp
    3. //-----------------------------------------------------------------------------
    4. #include "StdAfx.h"
    5. #include "acedCmdNF.h"
    6. #include "resource.h"
    7. //-----------------------------------------------------------------------------
    8. #define szRDS 采用RXST("")
    9. //-----------------------------------------------------------------------------
    10. //----- ObjectARX EntryPoint
    11. class CMyJoinApp : public AcRxArxApp {
    12. public:
    13.   CMyJoinApp() : AcRxArxApp() {}
    14.   virtual AcRx::AppRetCode On采用kInitAppMsg(void *pkt) {
    15.     AcRx::AppRetCode retCode = AcRxArxApp::On采用kInitAppMsg(pkt);
    16.     return (retCode);
    17.   }
    18.   virtual AcRx::AppRetCode On采用kUnloadAppMsg(void *pkt) {
    19.     AcRx::AppRetCode retCode = AcRxArxApp::On采用kUnloadAppMsg(pkt);
    20.     return (retCode);
    21.   }
    22.   virtual void RegisterServerComponents() {}
    23.   static void RivilisMyJoin() {
    24.     ads采用name en1;  ads采用point p;
    25.     while (acedEntSel(采用T("\nSelect first segment: "), en1, p) == RTNORM)
    26.     {
    27.       bool bConvertToPoly = false;
    28.       AcDbObjectId id1; acdbGetObjectId(id1, en1);
    29.       if (id1.objectClass() == AcDbLine::desc() ||
    30.           id1.objectClass() == AcDbArc::desc())
    31.       {
    32.         bConvertToPoly = true;
    33.       }
    34.       ads采用name en2;
    35.       if (acedEntSel(采用T("\nSelect next segment: "), en2, p) == RTNORM)
    36.       {
    37.         if (bConvertToPoly)
    38.           acedCommandS(RTSTR, 采用T("采用PEDIT"), RTENAME, en1, RTSTR, 采用T("采用YES"), RTSTR, 采用T("采用Join"),
    39.             RTENAME, en2, RTSTR, 采用T(""), RTSTR, 采用T(""), RTNONE);
    40.         else
    41.           acedCommandS(RTSTR, 采用T("采用PEDIT"), RTENAME, en1, RTSTR, 采用T("采用Join"),
    42.             RTENAME, en2, RTSTR, 采用T(""), RTSTR, 采用T(""), RTNONE);
    43.       }
    44.     }
    45.   }
    46. };
    47. //-----------------------------------------------------------------------------
    48. IMPLEMENT采用ARX采用ENTRYPOINT(CMyJoinApp)
    49. ACED采用ARXCOMMAND采用ENTRY采用AUTO(CMyJoinApp, Rivilis, MyJoin, MyJoin, ACRX采用CMD采用MODAL, NULL)
    复制代码

     

     

     

     

    JoinToPline 连接线段成多段线
  • TA的每日心情
    开心
    昨天 06:36
  • 签到天数: 15 天

    [LV.4]偶尔看看III

    105

    主题

    11

    回帖

    1308

    积分

    管理员

    积分
    1308
    QQ
     楼主| 发表于 2024-2-15 16:35:39 | 显示全部楼层
    1. //-----------------------------------------------------------------------------
    2. //----- acrxEntryPoint.cpp
    3. //-----------------------------------------------------------------------------
    4. #include "StdAfx.h"
    5. #include "acedCmdNF.h"
    6. #include "resource.h"
    7. //-----------------------------------------------------------------------------
    8. #define szRDS 采用RXST("")
    9. //-----------------------------------------------------------------------------
    10. //----- ObjectARX EntryPoint
    11. class CMyJoinApp : public AcRxArxApp {
    12. public:
    13.   CMyJoinApp() : AcRxArxApp() {}
    14.   virtual AcRx::AppRetCode On采用kInitAppMsg(void *pkt) {
    15.     AcRx::AppRetCode retCode = AcRxArxApp::On采用kInitAppMsg(pkt);
    16.     return (retCode);
    17.   }
    18.   virtual AcRx::AppRetCode On采用kUnloadAppMsg(void *pkt) {
    19.     AcRx::AppRetCode retCode = AcRxArxApp::On采用kUnloadAppMsg(pkt);
    20.     return (retCode);
    21.   }
    22.   virtual void RegisterServerComponents() {}
    23.   static void RivilisMyJoin() {
    24.     // Check PEDITACCEPT sysvar
    25.     resbuf rb = { 0, RTSHORT, 0 };
    26.     acedGetVar(采用T("PEDITACCEPT"), &rb);
    27.     bool bPeditAccept = (rb.resval.rint == 1) ? true : false;
    28.     ads采用name en1;  ads采用point p;
    29.     while (acedEntSel(采用T("\nSelect first segment: "), en1, p) == RTNORM)
    30.     {
    31.       // if PEDITACCEPT == 1 then PEDIT no ask about converting
    32.       bool bConvertToPoly = false;
    33.       if (!bPeditAccept)
    34.       {
    35.         AcDbObjectId id1; acdbGetObjectId(id1, en1);
    36.         if (id1.objectClass() == AcDbLine::desc() ||
    37.           id1.objectClass() == AcDbArc::desc())
    38.         {
    39.           bConvertToPoly = true;
    40.         }
    41.       }
    42.       ads采用name en2;
    43.       if (acedEntSel(采用T("\nSelect next segment: "), en2, p) == RTNORM)
    44.       {
    45.         if (bConvertToPoly)
    46.           acedCommandS(RTSTR, 采用T("采用PEDIT"), RTENAME, en1, RTSTR, 采用T("采用YES"), RTSTR, 采用T("采用Join"),
    47.             RTENAME, en2, RTSTR, 采用T(""), RTSTR, 采用T(""), RTNONE);
    48.         else
    49.           acedCommandS(RTSTR, 采用T("采用PEDIT"), RTENAME, en1, RTSTR, 采用T("采用Join"),
    50.             RTENAME, en2, RTSTR, 采用T(""), RTSTR, 采用T(""), RTNONE);
    51.       }
    52.     }
    53.   }
    54. };
    55. //-----------------------------------------------------------------------------
    56. IMPLEMENT采用ARX采用ENTRYPOINT(CMyJoinApp)
    57. ACED采用ARXCOMMAND采用ENTRY采用AUTO(CMyJoinApp, Rivilis, MyJoin, MyJoin, ACRX采用CMD采用MODAL, NULL)
    复制代码

     

     

     

     

    JoinToPline 连接线段成多段线
  • TA的每日心情
    开心
    昨天 06:36
  • 签到天数: 15 天

    [LV.4]偶尔看看III

    105

    主题

    11

    回帖

    1308

    积分

    管理员

    积分
    1308
    QQ
     楼主| 发表于 2024-2-15 16:36:19 | 显示全部楼层
    1. //------------------------------------------------------------------------------
    2. class SubentityOverrule : public AcDbSubentityOverrule
    3. //------------------------------------------------------------------------------
    4. {
    5. public:
    6.   static SubentityOverrule* 采用pTheOverrule;
    7.   ACRX采用DECLARE采用MEMBERS(SubentityOverrule);
    8.   //--------------------------------------------------------------------------
    9.   bool isApplicable(const AcRxObject* pOverruledSubject) const
    10.   //--------------------------------------------------------------------------
    11.   {
    12.     if (pOverruledSubject->isA() == MyClass::desc())
    13.     {
    14.       MyClass* pMine = MyClass::cast(pOverruledSubject);
    15.       if (pMine != NULL)
    16.       {
    17.         return true;
    18.       }
    19.     }
    20.     return false;
    21.   }
    22.   //--------------------------------------------------------------------------
    23.   static void SubentityOverrule::AddOverrule()
    24.   //--------------------------------------------------------------------------
    25.   {
    26.     if (采用pTheOverrule != NULL)
    27.     {
    28.       return;
    29.     }
    30.     采用pTheOverrule = new SubentityOverrule();
    31.     Acad::ErrorStatus es = AcRxOverrule::addOverrule(MyClass::desc(), 采用pTheOverrule, true);
    32.     SubentityOverrule::setIsOverruling(true);
    33.   }
    34.   //--------------------------------------------------------------------------
    35.   static void SubentityOverrule::RemoveOverrule()
    36.   //--------------------------------------------------------------------------
    37.   {
    38.     if (采用pTheOverrule == NULL)
    39.     {
    40.       return;
    41.     }
    42.     SubentityOverrule::setIsOverruling(false);
    43.     Acad::ErrorStatus es = AcRxOverrule::removeOverrule(MyClass::desc(), 采用pTheOverrule);
    44.     delete 采用pTheOverrule;
    45.     采用pTheOverrule = NULL;
    46.   }
    47.   //--------------------------------------------------------------------------
    48.   Acad::ErrorStatus SubentityOverrule::getSubentPathsAtGsMarker(const AcDbEntity* pSubject, AcDb::SubentType type, Adesk::GsMarker gsMark, const AcGePoint3d& pickPoint,
    49.                   const AcGeMatrix3d& viewXform, int& numPaths, AcDbFullSubentPath*& subentPaths, int numInserts = 0, AcDbObjectId* entAndInsertStack = NULL)
    50.   //--------------------------------------------------------------------------
    51.   {
    52.     return  Acad::eOk;
    53.   }
    54.   //--------------------------------------------------------------------------
    55.   AcDbEntity* SubentityOverrule::subentPtr(const AcDbEntity* pSubject, const AcDbFullSubentPath& id)
    56.   //--------------------------------------------------------------------------
    57.   {
    58.     return NULL;
    59.   }
    60. };
    61. SubentityOverrule* SubentityOverrule::采用pTheOverrule = NULL;
    62. ACRX采用NO采用CONS采用DEFINE采用MEMBERS(SubentityOverrule, AcDbSubentityOverrule);
    复制代码

     

     

     

     

    JoinToPline 连接线段成多段线
  • TA的每日心情
    开心
    昨天 06:36
  • 签到天数: 15 天

    [LV.4]偶尔看看III

    105

    主题

    11

    回帖

    1308

    积分

    管理员

    积分
    1308
    QQ
     楼主| 发表于 2024-2-15 16:36:51 | 显示全部楼层
    1. //------------------------------------------------------------------------------
    2. Acad::ErrorStatus MyClass::subGetSubentPathsAtGsMarker(AcDb::SubentType type, Adesk::GsMarker gsMark, const AcGePoint3d& pickPoint,
    3.                                                                 const AcGeMatrix3d& viewXform, int& numPaths, AcDbFullSubentPath*& subentPaths, int numInserts, AcDbObjectId* entAndInsertStack) const
    4. //------------------------------------------------------------------------------
    5. {
    6.     BOOL bCtrl = KEY采用DOWN(VK采用CONTROL);
    7.     if (bCtrl)
    8.     {
    9.         return Acad::eNotImplementedYet;
    10.     }
    11.     else
    12.     {
    13.         return AcDbPolyline::subGetSubentPathsAtGsMarker(type, gsMark, pickPoint, viewXform, numPaths, subentPaths, numInserts, entAndInsertStack);
    14.     }
    15. }
    16. //------------------------------------------------------------------------------
    17. AcDbEntity* MyClass::subSubentPtr(const AcDbFullSubentPath& id) const
    18. //------------------------------------------------------------------------------
    19. {
    20.     BOOL bCtrl = KEY采用DOWN(VK采用CONTROL);
    21.     if (bCtrl)
    22.     {
    23.         return NULL;
    24.     }
    25.     else
    26.     {
    27.         return AcDbPolyline::subSubentPtr(id);
    28.     }
    29. }
    复制代码

     

     

     

     

    JoinToPline 连接线段成多段线
  • TA的每日心情
    开心
    昨天 06:36
  • 签到天数: 15 天

    [LV.4]偶尔看看III

    105

    主题

    11

    回帖

    1308

    积分

    管理员

    积分
    1308
    QQ
     楼主| 发表于 2024-2-15 17:29:13 | 显示全部楼层
    1. acedCommandS(RTSTR, 采用T("PEDIT"),
    2.                 RTSTR, 采用T("M"),
    3.                 RTPICKS, result,
    4.                 RTSTR, 采用T(""),
    5.                 RTSTR, 采用T("Y"),
    6.                 RTSTR, 采用T("J"),
    7.                 RTSTR, 采用T("1"),//表示模糊距离
    8.                 RTSTR, 采用T(""),
    9.                 RTSTR, 采用T(""),
    10.                 RTNONE);
    11. 解释:RTPICKS 是你要转变为多段线的选择集,它的类型是ads采用name的。
    12. acedCommandS(RTSTR, 采用T("PEDIT"),
    13.             RTENAME, entName,
    14.             RTSTR, 采用T("Y"),
    15.             RTSTR, 采用T("J"),
    16.             RTPICKS, result,//选择集,表示需要转换的实体集合。
    17.             RTSTR, 采用T(""), RTSTR, 采用T(""), RTNONE);
    18. 解释:RTENAME ,entName 表示选择一个需要转换为多段线的实体,只能是一个,它应该是属于集合resut的。
    复制代码

     

     

     

     

    JoinToPline 连接线段成多段线
  • TA的每日心情
    开心
    昨天 06:36
  • 签到天数: 15 天

    [LV.4]偶尔看看III

    105

    主题

    11

    回帖

    1308

    积分

    管理员

    积分
    1308
    QQ
     楼主| 发表于 2024-2-15 17:44:00 | 显示全部楼层
    1. PEDITACCEPT(系统变量)
    2. 自动将选定对象转换为多段线,而在使用 PEDIT 时不显示提示。
    3. 类型:        整数
    4. 保存位置:        注册表
    5. 初始值:        0
    6. 0        将显示提示,允许用户选择将选定对象转换为多段线
    7. 1        自动将选定对象转换为多段线,而不显示提示
    8. CAD 编辑多段线PEDIT命令使用
    9. PEDIT命令的使用:
    10. 在CAD的命令行中,输入PEDIT命令空格,选择要编辑的多段线,一定要是多段线。空格就可以进行修改了。
    11. 定义和用法:
    12. PEDIT编辑多段线,编辑多段线和三维多边形网格。PEDIT的常见用途包含合并二维多段线、将线条和圆弧转换为二维多段线以及将多段线转换为近似B样条曲线的曲线(拟合多段线)。
    复制代码

     

     

     

     

    JoinToPline 连接线段成多段线

    该用户从未签到

    主题

    0

    回帖

    0

    积分

    管理员

    积分
    0
    QQ
    发表于 2024-2-22 16:19:08 | 显示全部楼层
    1. //-----------------------------------------------------------------------------
    2. //----- acrxEntryPoint.cpp
    3. //-----------------------------------------------------------------------------
    4. #include "StdAfx.h"
    5. #include "resource.h"
    6. #include "dbJoinEntityPE.h"
    7. //-----------------------------------------------------------------------------
    8. #define szRDS 采用RXST("")
    9. //-----------------------------------------------------------------------------
    10. //----- ObjectARX EntryPoint
    11. class CJoinEntitiesApp : public AcRxArxApp {
    12. public:
    13.   CJoinEntitiesApp() : AcRxArxApp() {}
    14.   virtual AcRx::AppRetCode On采用kInitAppMsg(void* pkt) {
    15.     AcRx::AppRetCode retCode = AcRxArxApp::On采用kInitAppMsg(pkt);
    16.     return (retCode);
    17.   }
    18.   virtual AcRx::AppRetCode On采用kUnloadAppMsg(void* pkt) {
    19.     AcRx::AppRetCode retCode = AcRxArxApp::On采用kUnloadAppMsg(pkt);
    20.     return (retCode);
    21.   }
    22.   virtual void RegisterServerComponents() {  }
    23.   static void RivilisJoinEnts()
    24.   {
    25.     // filter for selectin lines and arcs
    26.     ACHAR* promptPtrs[] = {
    27.       采用T("\nSelect lines, arcs, polylines for getting polyline (ENTER - exit): "),
    28.       采用T("\nRemove lines, arcs, polylines from selection set: ")
    29.     };
    30.     ads采用name ss;
    31.     resbuf* rbFilter = acutBuildList(RTDXF0, 采用T("LINE,ARC,LWPOLYLINE"), RTNONE);
    32.     int rc = acedSSGet(采用T(":$"), promptPtrs, NULL, rbFilter, ss);
    33.     acutRelRb(rbFilter);
    34.     if (rc != RTNORM) return;
    35.     AcDbObjectIdArray ids;
    36.     if (ObjectIdArrayFromSelSet(ss, ids) != Acad::eOk) return;
    37.     AcDbObjectPointer<AcDbPolyline> pPoly; pPoly.create();
    38.     pPoly->setDatabaseDefaults();
    39.     AcArray<AcDbEntity*> ents; ents.setPhysicalLength(ids.length());
    40.     AcDbObjectPointer<AcDbCurve> c(ids[0], AcDb::kForRead);
    41.     if (c.openStatus() == Acad::eOk) {
    42.       AcGePoint3d ptStart, ptEnd;
    43.       c->getStartPoint(ptStart); c->getEndPoint(ptEnd);
    44.       pPoly->addVertexAt(0, asPnt2d(asDblArray(ptStart)), BulgeFromArc(c, false), 0, 0);
    45.       pPoly->addVertexAt(1, asPnt2d(asDblArray(ptEnd)), 0, 0, 0);
    46.     }
    47.     for (int i = 1; i < ids.length(); i++)
    48.     {
    49.       AcDbObjectPointer<AcDbCurve> c(ids[i], AcDb::kForRead);
    50.       if (c.openStatus() == Acad::eOk)
    51.         ents.append(c);
    52.     }
    53.     if (ents.length() > 0)
    54.     {
    55.       AcDbJoinEntityPE* pPE = AcDbJoinEntityPE::cast(pPoly->queryX(AcDbJoinEntityPE::desc()));
    56.       AcGeIntArray aInts;
    57.       Acad::ErrorStatus es = pPE->joinEntities(pPoly, ents, aInts);
    58.       if (es != Acad::eOk)
    59.       {
    60.         acutPrintf(采用T("\nError pPE->joinEntities(pPoly, ents, aInts) = %s"), acadErrorStatusText(es));
    61.         return;
    62.       }
    63.     }
    64.     AcDbBlockTableRecordPointer pSpace(acdbCurDwg()->currentSpaceId(), AcDb::kForWrite);
    65.     if (pSpace.openStatus() != Acad::eOk) return;
    66.     pSpace->appendAcDbEntity(pPoly);
    67.   }
    68.   /// <summary>
    69.   /// Getting AcDbObjectIdArray from SelectionSet
    70.   /// </summary>
    71.   /// <param name="sset">SelectionSet</param>
    72.   /// <param name="ids">AcDbObjectIdArray</param>
    73.   /// <returns></returns>
    74.   static Acad::ErrorStatus ObjectIdArrayFromSelSet(ads采用name sset, AcDbObjectIdArray& ids)
    75.   {
    76.     Acad::ErrorStatus es = Acad::eOk;
    77.     Adesk::Int32 nset = -1;
    78.     if (acedSSLength(sset, &nset) != RTNORM) return Acad::eAmbiguousInput;
    79.     ids.setLogicalLength(nset);
    80.     ads采用name en;
    81.     AcDbObjectId id;
    82.     for (long i = 0; i < nset; i++) {
    83.       if (acedSSName(sset, i, en) == RTNORM) {
    84.         if ((es = acdbGetObjectId(id, en)) != Acad::eOk) return es;
    85.         ids[i] = id;
    86.       }
    87.     }
    88.     return Acad::eOk;
    89.   }
    90.   /// <summary>
    91.   /// Getting bulge for curve
    92.   /// </summary>
    93.   /// <param name="c">curve pointer</param>
    94.   /// <param name="clockwise">clockwise or counterclockwise.</param>
    95.   /// <returns></returns>
    96.   static double BulgeFromArc(AcDbCurve* c, bool clockwise)
    97.   {
    98.     double bulge = 0.0;
    99.     AcDbArc* a = AcDbArc::cast(c);
    100.     if (a == NULL) return bulge;
    101.     double newStart =
    102.       (a->startAngle() > a->endAngle()) ?
    103.       (a->startAngle() - 8 * atan(1.0)) :
    104.       (a->startAngle());
    105.     bulge = tan((a->endAngle() - newStart) / 4.0);
    106.     if (clockwise) bulge = -bulge;
    107.     return bulge;
    108.   }
    109. };
    110. //-----------------------------------------------------------------------------
    111. IMPLEMENT采用ARX采用ENTRYPOINT(CJoinEntitiesApp)
    112. ACED采用ARXCOMMAND采用ENTRY采用AUTO(CJoinEntitiesApp, Rivilis, JoinEnts, JoinEnts, ACRX采用CMD采用MODAL | ACRX采用CMD采用USEPICKSET, NULL)
    复制代码
    JoinToPline 连接线段成多段线
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

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

    GMT+8, 2024-11-1 07:55 , Processed in 0.167277 second(s), 28 queries .

    Powered by Discuz! X3.5

    © 2001-2024 Discuz! Team.

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