请问如何让插入的数值随时清晰可见,无论比例,无论图幅,就比如cad的菜单内的文字显示高度始终固定,不会造成看不见的现象
- (princ "\n 程序:(XKBUILD)统计线段长度命令:ll")
- (defun C:ll (/ CURVE TLEN SS N SUMLEN a b txtheight viewport viewcenter viewsizescale)
- (vl-load-com)
- (setq SUMLEN 0)
- (setq SS (ssget '((0 . "CIRCLE,ELLIPSE,LINE,*POLYLINE,SPLINE,ARC"))))
- (setq N 0)
- (repeat (sslength SS)
- (setq CURVE (vlax-ename->vla-object (ssname SS N)))
- (setq TLEN (vlax-curve-getdistatparam CURVE (vlax-curve-getendparam CURVE)))
- (setq SUMLEN (+ SUMLEN TLEN))
- (setq N (1+ N))
- )
-
- (princ (strcat "\n共选择" (itoa (sslength SS)) "条线段,总长" (rtos SUMLEN 2 0) "mm.")) ; 显示总长度,单位为毫米
- (setq SUMLEN (/ SUMLEN 1000.0)) ; 将总长度转换为米
- (setq b (rtos SUMLEN 2 2)) ; 将总长转换成字符串,设置为两个精度,即小数点后两位
- (setq a (getpoint "\n屏幕单击插入点")) ; 指定插入点
- ;; 获取当前视口
- (setq viewport (vla-get-ActiveViewport (vla-get-ActiveDocument (vlax-get-acad-object))))
- ;; 获取视口中心和尺寸
- (setq viewcenter (vlax-get viewport 'Center))
- (setq viewsizescale (vlax-get viewport 'Height))
- ;; 计算文字高度,设置为视口高度的1/100
- (setq txtheight (/ viewsizescale 100))
- ;; 创建文字图元
- (entmake
- (list
- '(0 . "TEXT")
- (cons 10 a) ; 插入点
- (cons 40 txtheight) ; 文字高度
- (cons 1 b) ; 文字内容
- '(7 . "Standard")
- '(72 . 1)
- (cons 11 (list (car a) (+ (cadr a) txtheight))) ; 对齐插入点
- )
- )
- (princ)
- )
|