Author Topic: Mass Reverse Lines to Most Readable  (Read 1330 times)

0 Members and 1 Guest are viewing this topic.

cgeorg13

  • Guest
Mass Reverse Lines to Most Readable
« on: August 20, 2015, 01:52:22 PM »
Hello all,

Is there a way to be able to run the reverse command on a large selection set but only have it reverse the lines that are unreadable?
I'm wondering if it could be like Torient (text orient) in how it has an option to just reverse all text/mtext/leaders/etc. to the most readable direction and feel like this could be implemented to work on lines and polylines.
« Last Edit: August 21, 2015, 11:17:26 AM by cgeorg13 »

mkweaver

  • Bull Frog
  • Posts: 352
Re: Mass Reverse Lines to Most Readable
« Reply #1 on: August 25, 2015, 09:40:08 AM »
This will work for lines.  Anything else will take a bit more work.


Code: [Select]
(defun c:FixLineOrientation (/ ss1 SwapEndPoints)
  (defun SwapEndPoints (ent / elist p0 p1 ang)
    (setq
      elist (entget ent)
      p0    (cdr (assoc 10 elist))
      p1    (cdr (assoc 11 elist))
      ang   (angle p0 p1)
    )
    (if (and
  (> ang (/ pi 2))
  (< ang (* (/ pi 2) 3))
)
      (progn
(setq
  elist (subst (cons 10 p1) (assoc 10 elist) elist)
  elist (subst (cons 11 p0) (assoc 11 elist) elist)
)
(entmod elist)
      )
    )
  )
  (if
    (and (setq ss1 (ssget '((0 . "LINE"))))
(< 0 (sslength ss1))
    )

     (mapcar
       (function
(lambda (ent)
   (SwapEndPoints ent)
)
       )
       (vl-remove-if
'null
(vl-remove-if-not
   (function (lambda (e) (= 'ENAME (type e))))
   (apply 'append (ssnamex ss1))
)
       )
     )
  )
  (princ)
) ;end c:FixLineOrientation