;| Routine converted from old VBA macro writen by Matt Kolberg Conversion done by Jeff Mishler, January 2014 Rotates selected points to align with selected alignment. |; (defun c:ptsalign (/ align bearing dist east idx inrange north off os pt ptent range ssalign sspts sta) (if (and (princ "\Select points: ") (setq sspts (ssget '((0 . "AECC_COGO_POINT")))) (princ "\nSelect alignment: ") (setq ssalign (ssget ":S" '((0 . "AECC_ALIGNMENT")))) (setq dist (getdist "\nMaximum offset from alignment: ")) (setq leftorright 0) ) (progn (setq os 0 range 0 idx -1 align (vlax-ename->vla-object (ssname ssalign 0)) ) (initget 128 "Clockwise cOunterclockwise No") (setq str (getkword "\n...rotate Clockwise, cOunterclockwise, No extra rotation [No]...: ")) (cond (( = str "Clockwise") (setq LeftOrRight (- (* pi 0.5)))) ((= str "cOunterclockwise") (setq LeftOrRight (* pi 0.5))) (t (setq LeftOrRight 0)) ) (while (setq ptent (ssname sspts (setq idx (1+ idx)))) (setq pt (vlax-ename->vla-object ptent) east (vlax-get pt 'easting) north (vlax-get pt 'northing) ) (if (= 0 (setq inrange (vlax-invoke-method align 'stationoffsetex east north 0.0001 'sta 'off))) (progn (if (> (abs off) dist) (setq os (1+ os)) (progn (vlax-invoke-method align 'pointlocationex sta off 0.0001 'east 'north 'bearing) (cond ((and (>= bearing 0) (<= bearing (* 0.5 pi))) (setq bearing (- (* 0.5 pi) bearing)) ) ((and (> bearing (* 0.5 pi)) (< bearing pi)) (setq bearing (- (* 2 pi) (- bearing (* 0.5 pi)))) ) ((and (>= bearing pi) (< bearing (* 1.5 pi))) (setq bearing (- (* 1.5 pi) (- bearing pi))) ) (t (setq bearing (- pi (- bearing (* 1.5 pi))))) ) (if (minusp off) (setq bearing (+ bearing pi)) ) (vlax-put pt 'rotation (+ bearing LeftOrRight)) (vlax-put pt 'labelrotation (+ bearing LeftOrRight)) ) ) ) (setq range (1+ range)) ) ) (if (> os 0) (if (= 1 os) (princ "\nThere was 1 point outside the max offset.") (princ (strcat "\nThere were " (itoa os) " points outside the max offset.")) ) ) (if (> range 0) (if (= 1 range) (princ "\nThere was 1 point not adjacent to alignment.") (princ (strcat "\nThere were " (itoa range) " points not adjacent to alignment.")) ) ) ) ) (princ) )