这是我的版本,可以根据用户的选择选择垂直或水平线/多段线。
- (defun c:Test (/ sel ss go)
- (vl-load-com)
- ;;;; ******* Tharwat 14. June . 2012 ******* ;;;;;;
- ;;;; This peice of code to select Horizontal or Vertical ;;;;;
- ;;;; lines or Polylines according to user's choose ;;;;;
- (defun Catch (ang1 ang2 ss)
- ((lambda (l / i n sn e x p1 p2)
- (while (setq sn (ssname ss (setq l (1+ l))))
- (setq e (entget sn))
- (if (wcmatch (cdr (assoc 0 (entget sn))) "*POLYLINE")
- (progn
- (setq i 0
- n 0
- )
- (repeat (setq x (fix (vlax-curve-getendparam sn)))
- (if
- (or
- (equal
- (angle (setq p1 (vlax-curve-getpointatparam sn i))
- (setq p2 (vlax-curve-getpointatparam
- sn
- (setq i (1+ i))
- )
- )
- )
- ang1
- )
- (equal (angle p1 p2) ang2)
- )
- (setq n (1+ n))
- )
- )
- (if (eq n x)
- (ssadd sn sel)
- )
- )
- (if
- (or (eq (angle (cdr (assoc 10 e)) (cdr (assoc 11 e))) ang1)
- (eq (angle (cdr (assoc 10 e)) (cdr (assoc 11 e))) ang2)
- )
- (ssadd sn sel)
- )
- )
- )
- )
- -1
- )
- (princ)
- )
- (if
- (and (setq sel (ssadd))
- (progn
- (initget "Horizontal Vertical")
- (setq go (getkword "\n Choose one [Horizonta/Vertical] :"))
- )
- (setq ss (ssget "_:L" '((0 . "*POLYLINE,LINE"))))
- )
- (if (eq go "Horizontal")
- (Catch 0.0 pi ss)
- (Catch (/ pi 2.) (* pi 1.5) ss)
- )
- )
- (if (> (sslength sel) 0)
- (sssetfirst nil sel)
- )
- (princ)
- )
|