怎样能实现图元最大尺寸标注
各位大大,小弟想实现下图的效果,奈何看了几个lsp 还是不会写,完全没有头绪,谁知道怎样能实现这样的效果呢。(defun ayGetSSBoundBox (SS1 / i entName1 PtBox1 minPt maxPt PtLB PtRT)
(vl-load-com)
(setq i 0)
(repeat (sslength SS1)
(setq entName1 (ssname SS1 i))
(vla-GetBoundingBox (vlax-ename->vla-object entName1) 'PtLB 'PtRT)
(setq PtLB (vlax-safearray->list PtLB))
(setq PtRT (vlax-safearray->list PtRT))
(if (= minPt nil)
(setq minPt PtLB)
(progn;else
(if (> (car minPt) (car PtLB)) (setq minPt (List (car PtLB) (cadr minPt))))
(if (> (cadr minPt) (cadr PtLB)) (setq minPt (List (car minPt) (cadr PtLB))))
)
)
(if (= maxPt nil)
(setq maxPt PtRT)
(progn;else
(if (< (car maxPt) (car PtRT)) (setq maxPt (List (car PtRT) (cadr maxPt))))
(if (< (cadr maxPt) (cadr PtRT)) (setq maxPt (List (car maxPt) (cadr PtRT))))
)
)
(setq i (+ i 1))
)
(if (<= (distance minPt maxPt) 0.0)
(setq PtBox nil)
(setq PtBox (list minPt maxPt))
)
)
(defun c:fw ()
(command "osmode" 0 "_.ucs" "w")
(princ"\n请选择:")
(while (not (setq SS1 (ssget))))
(setq Ptbox (ayGetSSBoundBox SS1))
(progn
(setq PtBL (car PtBox))
(setq PtTR (cadr PtBox))
(setq PtBR (list (car PtTR) (cadr PtBL)))
(setq PtTL (list (car PtBL) (cadr PtTR)))
)
(setq a1 (distance PtBL PtTL))
(setq b1 (distance PtTR PtTL))
(setq pt (getpoint "指定插入点"))
(command "text" pt "16" "0" (strcat "长x宽" (rtos b1 2 2)"×"(rtos a1 2 2)""))
(princ)
)
支持直线、块内直线,8个方向的标注均可生成
本帖最后由 zhangrunze 于 2024-3-27 15:28 编辑
xiao88gang 发表于 2023-3-16 17:10
(defun ayGetSSBoundBox (SS1 / i entName1 PtBox1 minPt maxPt PtLB PtRT)
(vl-load-com)
(setq i 0)
...感谢分享~
这个只能生成文本,没有标注~
要是能批量就好了~
页:
[1]