请问如何判断直线的两个端点都在屏幕上?
请问如何判断直线的两个端点都在屏幕上?;; 如果p1 p2 都在屏幕内,则
(cond
((and
(ssget p1 '((0 . "LINE")))
(ssget p1 '((0 . "LINE")))
)
(command "dimlinear" p1 p2 "\\")
)
(T
;;否则
(while (not (setq oo (getpoint o"\n请指定标注第二点: "))))
(command "dimlinear" o oo pause)
))
Command: L
LINE Specify first point: 0,0
Specify next point or : 2,2
Specify next point or :
Command: '_zoom
Specify corner of window, enter a scale factor (nX or nXP), or
<real time>: _w
Specify first corner: Specify opposite corner:
===>使该线端点屏幕外
Command: (ssget '(0 0))
nil
Command: (ssget '(2 2))
nil
Andyhon 发表于 2018-6-10 18:52
Command: L
LINE Specify first point: 0,0
看得不是很懂,不能用 zoom 吧?我是要:
(setq o(getpoint"\n请点选直线:"))
(setq ss(ssget"c"o o))
然后判断直线 ss 的两个端点是否都在当前屏幕可见的范围之内 重点不在zoom...
如上例当 LINE 的两端点皆在屏幕外时
用以 ssget 作选取点返回 nil 本帖最后由 elitefish 于 2018-6-10 20:16 编辑
返回当前屏幕的左下角与右上角坐标,两点均在该范围内就算在屏幕上,函数在下贴
(defun EF:View-Vport (
/
VSMax VSMin ViewCTR
fHeight fWidth fScale
)
(setq VSMax (getvar 'VSMAX))
(setq VSMin (getvar 'VSMIN))
(setq VIEWCTR (getvar 'VIEWCTR))
(setq fHeight (- (cadr VSMax) (cadr VSMin)))
(setq fWidth (- (car VSMax) (car VSMin)))
(setq fScale (/ fWidth fHeight))
(setq fHeight (getvar 'VIEWSIZE))
(setq fWidth (* fHeight fScale))
(setq VSMin (mapcar '- ViewCTR (list (/ fWidth 2) (/ fHeight 2) 0)))
(setq VSMax (mapcar '+ ViewCTR (list (/ fWidth 2) (/ fHeight 2) 0)))
(list VSMin VSMax)
) 唉,还是看不懂,,, 那儿卡了? 请拿您的 实地图面(*.dwg)来说事... ;;gxl-Sys-GetScreenCoords 取得当前绘图区屏幕的左下角和右上角的坐标
;;返回:((x1 y1 z1)(x2 y2 z2))
(defun gxl-Sys-GetScreenCoords (/ c03 c08 c04 c05 c07 c06 c09 c01 c02)
(setq c03 (getvar "viewctr")
c03 (trans c03 1 2)
c08 (getvar "viewsize")
c04 (getvar "screensize")
c07 (car c04)
c06 (cadr c04)
c09 (/ (* c08 c07) c06)
c01 (list (- (car c03) (* 0.5 c09)) (- (cadr c03) (* 0.5 c08)))
c02 (list (+ (car c03) (* 0.5 c09)) (+ (cadr c03) (* 0.5 c08)))
c01 (trans c01 2 1)
c02 (trans c02 2 1)
)
(list c01 c02)
)