试了大半夜 初步调整成这样 大家看看对不对 水平线的: (defun c:ttt(/ ss n i ent1 ang1) (setq ss (ssget '((0 . "line")))) (if ss (setq n (sslength ss)) ) (setq i 0) (while (< i n) (setq ent1 (ssname ss i)) (setq p1 (entget ent1)) (setq ang1 (angle (dxf 10 p1)(dxf 11 p1))) (if (not(or(= ang1 0)(= ang1 pi)(= dang (- 0 pi)))) (ssdel ent1 ss)) (if (not(or(= ang1 0)(= ang1 pi)(= dang (- 0 pi)))) (setq i (- i 1))) (if (not(or(= ang1 0)(= ang1 pi)(= dang (- 0 pi)))) (setq n (- n 1))) (setq i (1+ i)) ) (command "erase" ss "") (princ) );其中最后的SS为处理过的选择集,就是我们要的水平线 (defun dxf (code elist) (cdr (assoc code elist))) 垂直线的: (defun c:czz(/ ss n i ent1 ang1) (setq ss (ssget '((0 . "line")))) (if ss (setq n (sslength ss)) ) (setq i 0) (while (< i n) (setq ent1 (ssname ss i)) (setq p1 (entget ent1)) (setq ang1 (angle (dxf 10 p1)(dxf 11 p1))) (if (not(or(= ang1 (/ pi 2))(= ang1 (- 0 (/ pi 2)))(= ang1 (+ pi (/ pi 2)))(= ang1 (- 0 (+ pi (/ pi 2)))))) (ssdel ent1 ss)) (if (not(or(= ang1 (/ pi 2))(= ang1 (- 0 (/ pi 2)))(= ang1 (+ pi (/ pi 2)))(= ang1 (- 0 (+ pi (/ pi 2)))))) (setq i (- i 1))) (if (not(or(= ang1 (/ pi 2))(= ang1 (- 0 (/ pi 2)))(= ang1 (+ pi (/ pi 2)))(= ang1 (- 0 (+ pi (/ pi 2)))))) (setq n (- n 1))) (setq i (1+ i)) ) (command "erase" ss "") (princ) ));其中最后的SS为处理过的选择集,就是我们要的垂直线 (defun dxf (code elist) (cdr (assoc code elist)))
|