如何快速实现多个多段线进行标注
如图所示,我想让a的内容变成B的内容,标注部分只标注上面和左边,A的内容为封闭的多段线,该如何写这样的程序呢,求大佬解决
(defun c:NM (/ sc h doldos oldla ss lst n obj minx miny maxxmaxy pt1 ss
pt2 pt3)
(prompt "\n请选择要标注的对象")
(setq ss (ssget))
(setq sc (getvar "dimscale"))
(setq h (getvar "dimtxt"))
(setq d (getvar "dimgap"))
(setq oldos (getvar "osmode"))
(setq oldla (getvar "clayer"))
(command "_.UNDO" "BE")
(setvar "cmdecho" 0)
(setvar "osmode" 0)
(repeat (setq n (sslength ss))
(setq obj (vlax-ename->vla-object (ssname ss (setq n (1- n)))))
(vla-getboundingbox obj 'x 'y)
(setq lst (cons (vlax-safearray->list y)
(cons (vlax-safearray->list x) lst)
)
)
)
(setqminx (car (vl-sort (mapcar 'car lst) '<))
miny (car (vl-sort (mapcar 'cadr lst) '<))
maxx (car (vl-sort (mapcar 'car lst) '>))
maxy (car (vl-sort (mapcar 'cadr lst) '>))
)
(setq pt1 (list minx miny))
(setq pt2 (list minx maxy))
(setq pt3 (list maxx maxy))
(command "dimlinear"
pt1
pt2
(polar pt1 (+ (* -1.5 pi) (angle pt1 pt2)) (* sc (+ d h h h)))
)
(command "dimlinear"
pt2
pt3
(polar pt2 (+ (* -1.5 pi) (angle pt2 pt3)) (* sc (+ d h h h)))
)
(setvar "osmode" oldos)
(setvar "clayer" oldla)
(setvar "cmdecho" 1)
(command "_.UNDO" "E")
(princ)
(prin1)
) 此版本支持多个多段线对象
(defun c:NM (/ sc h doldos oldla ss lst n obj minx miny maxxmaxy pt1 ss
pt2 pt3)
(prompt "\n请选择要标注的对象")
(setq sc (getvar "dimscale"))
(setq h (getvar "dimtxt"))
(setq d (getvar "dimgap"))
(setq oldos (getvar "osmode"))
(setq oldla (getvar "clayer"))
(command "_.UNDO" "BE")
(setvar "cmdecho" 0)
(setvar "osmode" 0)
(mapcar '(lambda(a / lst maxx maxy minx miny n obj pt1 pt2 pt3 ss)
(setq ss(ssadd a))
(repeat (setq n (sslength ss))
(setq obj (vlax-ename->vla-object (ssname ss (setq n (1- n)))))
(vla-getboundingbox obj 'x 'y)
(setq lst (cons (vlax-safearray->list y)
(cons (vlax-safearray->list x) lst)
)
)
)
(setqminx (car (vl-sort (mapcar 'car lst) '<))
miny (car (vl-sort (mapcar 'cadr lst) '<))
maxx (car (vl-sort (mapcar 'car lst) '>))
maxy (car (vl-sort (mapcar 'cadr lst) '>))
)
(setq pt1 (list minx miny))
(setq pt2 (list minx maxy))
(setq pt3 (list maxx maxy))
(command "dimlinear"
pt1
pt2
(polar pt1 (+ (* -1.5 pi) (angle pt1 pt2)) (* sc (+ d h h h)))
)
(command "dimlinear"
pt2
pt3
(polar pt2 (+ (* -1.5 pi) (angle pt2 pt3)) (* sc (+ d h h h)))
)
)
(vl-remove-if-not '(lambda(x)(= 'ENAME (type x))) (mapcar 'cadr (ssnamex (ssget '((0 . "*LINE,*POLYLINE"))))))
)
(setvar "osmode" oldos)
(setvar "clayer" oldla)
(setvar "cmdecho" 1)
(command "_.UNDO" "E")
(princ)
) xj6019 发表于 2022-10-19 17:52
(defun c:NM (/ sc h doldos oldla ss lst n obj minx miny maxxmaxy pt1 ss
pt2 pt3)
...
大佬牛,谢谢,学到了 xj6019 发表于 2022-10-19 18:30
此版本支持多个多段线对象
谢谢大师,很实用,工作中需要防呆,所以不能有两个长宽相同的多段线,长宽必须唯一,我在想如果在标注长宽的同时,能不能把长宽一样的多段线用相同的颜色来显示,这样一看就知道是哪两个或哪几个多段线是一样的,一目了然,请帮忙看看,谢谢 !
cj52000 发表于 2022-10-19 21:22
谢谢大师,很实用,工作中需要防呆,所以不能有两个长宽相同的多段线,长宽必须唯一,我在想如果在标注长 ...
搞不了,学艺未精, 这玩意判断太费劲了 向高手学习666 xj6019 发表于 2022-10-19 18:30
此版本支持多个多段线对象
大佬尺寸偏移距离能设置吗?:handshake h806600727 发表于 2022-10-21 11:22
大佬尺寸偏移距离能设置吗?
sc 换成你喜欢的比例就可以改了
xj6019 发表于 2022-10-21 11:24
sc 换成你喜欢的比例就可以改了
好的,谢谢大佬:lol
页:
[1]
2