;; ▓ (lt:pts-angle-Sort <点集> <角度>) ;; [功能] 根据角度将点集重新排序 ;; 测试 (defun c:tt (/ p lst) (while (setq p (getpoint "\n拾取:")) (setq lst (cons p lst))) (setvar 'osmode 0) (apply 'command (cons "_.pline" (lt:pts-angle-Sort lst (getangle "\n角度:")))) (command "") ) (defun lt:pts-angle-Sort (pts ang / pt 0.5pi n p lst1 lst2 dis1 dis2) (setq pt (car pts) pts (cdr pts) 0.5pi (/ pi 2)) (repeat (setq n (length pts)) (setq n (1- n)) (if (equal (angle pt (setq p (nth n pts))) ang 0.5pi) (setq lst1 (cons p lst1) dis1 (cons (distance pt p) dis1)) (setq lst2 (cons p lst2) dis2 (cons (distance pt p) dis2)) ) ) (append (mapcar '(lambda (x) (nth x lst1)) (vl-sort-i dis1 '>)) (list pt) (mapcar '(lambda (x) (nth x lst2)) (vl-sort-i dis2 '<)) ) ) |