还有另一种方法,使用grread和LM:grsnap-
- ; Vertical/Horizontal XLINE demo
- ; Requires:
- ; http://www.lee-mac.com/grsnap.html
- (defun C:test ( / *error* )
-
- (defun *error* ( m )
- (redraw)
- (and m (princ m)) (princ)
- ); defun *error*
-
- (cond
- ( (not LM:grsnap:snapfunction) (alert "\nPlease define 'LM:grsnap:snapfunction'") )
- (
- (
- (lambda ( / osf osm a1 a2 vec s g k v d )
- '(84 104 105 115 32 100 101 109 111 32 119 114 105 116 116 101 110 32 98 121 32 71 114 114 114 33 32 58 41)
- (setq osf (LM:grsnap:snapfunction))
- (setq osm (getvar 'osmode))
- (mapcar 'set '(a1 a2 vec) '(0 1. (11 1.0 0.0 0.0)))
- (princ "\nSpecify point for the xline [V]ertical: ")
- (while (not s) (mapcar 'set '(k v) (setq g (grread t 15 0)))
- (cond
- ( (or (eq s '(2 13)) (= 25 k))
- (setq s t)
- )
- ( (= k 5)
- (setq d (* 3 (getvar 'viewsize)))
- (redraw)
- (setq v (osf (cadr g) osm))
- (grdraw (polar v (* a1 PI) d) (polar v (* a2 PI) d) 1 3)
- )
- ( (= k 3)
- (entmakex
- (append
- '( (0 . "XLINE") (100 . "AcDbEntity") (67 . 0) (100 . "AcDbXline") )
- (list (cons 10 (trans (osf (cadr g) osm) 1 0)))
- (list vec)
- )
- ); entmakex
- (setq s t)
- )
- ( (and (= k 2) (member v '(86 118)))
- (princ "\nSpecify point for the xline [H]orizontal: ")
- (mapcar 'set '(a1 a2 vec) '(0.5 1.5 (11 0.0 1.0 0.0)))
- )
- ( (and (= k 2) (member v '(72 104)))
- (princ "\nSpecify point for the xline [V]ertical: ")
- (mapcar 'set '(a1 a2 vec) '(0 1. (11 1.0 0.0 0.0)))
- )
- ); cond
- ); while
- ); lambda
- )
- )
- ); cond
- (*error* nil) (princ)
- ); defun
|