;;; Rotate selected side of polyline to zero
;;; Created by phanaem
;;; Saved from: https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/rotate-a-selected-side-of-a-polyline-to-zero-degrees-in-autolisp/td-p/7563715
;;; It is important where you make the selection.
;;; The nearest vertex is the base point of the rotation. The other vertex of the clicked segment is the reference point
(defun c:pz ( / e p a p1 p2)
(if
(setq e (entsel "\nSelect polyline segment to rotate to zero: "))
(progn
(setq p (cadr e)
e (car e)
a (vlax-curve-getparamatpoint e (vlax-curve-getclosestpointto e p))
p1 (vlax-curve-getpointatparam e (if (< (- a (fix a)) 0.5) (fix a) (1+ (fix a))))
p2 (vlax-curve-getpointatparam e (if (< (- a (fix a)) 0.5) (1+ (fix a)) (fix a)))
)
(command "_rotate" e "" "_non" p1 "_r" "_non" p1 "_non" p2 0.0)
)
)
(princ)
)
(c:pz)

Advertisements