Author Topic: Reversing Polylines  (Read 8295 times)

0 Members and 1 Guest are viewing this topic.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10376
Reversing Polylines
« Reply #15 on: March 20, 2004, 11:49:53 PM »
Thanks Se7en for the news group link in the routine. :)

My search turned up another one.

Haven't tried eather.

Code: [Select]
; function to reverse the order of vertex points on a polyline
;   ie, to change the order from clockwise to counter clockwise
;   or vise versa.

;revpoly.lsp

(defun revpoly (/ poly1 polyorg polynm poly2 poly3 poly5)
  (setq poly1 (entget (car (entsel "\nPick polyline to reverse:  ")))
        polyorg (cdr (car poly1))
  ); end setq
  (while (/= (cdr (assoc 0 poly1)) "SEQEND")
    (setq polynm (cdr (car poly1))
          poly2 (append poly2 (list
                                (list
                                  (assoc 0 poly1)
                                  (assoc 8 poly1)
                                  (assoc 10 poly1)
                                ); end list
                              ); end list
                ); end append
          poly1 (entget (entnext polynm))
    ); end setq
  ); end while
  (setq poly3 (reverse (cdr poly2))
        poly5 (car (reverse (cdr poly2)))
        poly1 (append (list (car poly2)) poly3 (list poly5) (list '((0 . "SEQEND"))))
  ); end setq
  (command "erase" polyorg "")
  (foreach a poly1
;     (print a)
    (entmake a)
  ); end foreach
); end defun
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.