Author Topic: [XDrX-PlugIn(157)] The internal curves of a closed polyline are aligned  (Read 68 times)

0 Members and 1 Guest are viewing this topic.

xdcad

  • Swamp Rat
  • Posts: 505

Code: [Select]
(defun c:xdtb_plclose ( / ept ints nearpt outline pts spt ss ss1 x y)
  (if (and (setq ss (xdrx-ssget
      (xdrx-string-multilanguage
"\n选择封闭多段线<退出>:"
"\nSelect a closed polyline<Exit>:"
      )
      '((0 . "*polyline")
(-4 . "&=")
(70 . 1)
       )
    )
   )
      )
    (progn
      (xdrx-begin)
      (xdrx-document-safezoom ss)
      (setq pts (xdrx-getpropertyvalue outline "vertices"))
      (mapcar
'(lambda (x)
   (if (and (setq ss1 (ssget "cp"
     (xdrx-getpropertyvalue x "vertices")
     '((0 . "*polyline,line,arc")
       (-4 . "<not")
       (-4 . "&=")
       (70 . 1)
       (-4 . "not>")
      )
      )
    )
    (if (ssmemb x ss1)
      (ssdel x ss1)
      ss1
    )
    (> (sslength ss1) 0)
       )
     (progn
       (mapcar
'(lambda (y)
    (if (setq ints (xdrx-entity-intersectwith x y 2))
      (progn
(setq
  spt (xdrx-curve-getstartpoint y)
  ept (xdrx-curve-getendpoint y)
  nearpt (xdrx-points-nearpt spt ints)
)
(xdrx-curve-setsptept y spt nearpt)
(setq
  nearpt (xdrx-points-nearpt ept ints)
)
(xdrx-curve-setsptept y ept nearpt)
      )
    )
  )
(xdrx-ss->ents ss1)
       )
     )
   )
)
(xdrx-ss->ents ss)
      )
      (xdrx-end)
    )
  )
  (princ)
)
The code I wrote uses XDRX-API,which can be downloaded from github.com and is updated at any time.
===================================
https://github.com/xdcad
https://sourceforge.net/projects/xdrx-api-zip/
http://bbs.xdcad.net