lisp的单Xline
(command "xline""H")我需要通过屏幕上的选定点绘制一条单线。
并找到拾取点的坐标。
上述代码正在工作,但在插入一条xline后不会停止。 不使用命令调用很容易:
(defun c:foo (/ p)
(if (setq p (getpoint "\Pick a point: "))
(entmakex (list '(0 . "XLINE")
'(100 . "AcDbEntity")
'(67 . 0)
'(8 . "XLINE")
'(100 . "AcDbXline")
(cons 10 p)
'(11 1.0 0.0 0.0)
)
)
)
(princ)
) 您可能还会发现这个自定义xline程序很有用。 谢谢你们两位提供代码。但是我需要在点拾取之前显示xline。帮助xline的点待定。 (command "_.xline" "_horizontal" pause "")
(getvar 'lastpoint)
也许橡皮筋有帮助?
(setvar 'polarmode 1 )
(and
(setq p1 (getpoint "\nSpecify 1st point.. "))
(setq p2 (getpoint p1 "Specify 2nd point.. "))
(apply 'vla-AddXline
(cons msps
(mapcar ''((x) (vlax-3d-point (trans x 1 0))) (list p1 p2))
)
)
)
还有另一种方法,使用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 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 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 ertical: ")
(mapcar 'set '(a1 a2 vec) '(0 1. (11 1.0 0.0 0.0)))
)
); cond
); while
); lambda
)
)
); cond
(*error* nil) (princ)
); defun
我的0.02美元setvar snapang
带光标大小100 是的,光标设置更好。
页:
[1]