求输入tt,点击线条,在线条上生成对应文字,自动识别
求输入tt,点击线条,在线条上生成对应文字,自动识别没啥好处,纯体力活呀
(defun C:NM (/ ss xj-en2pt zuhelst)
(defun xj-en2pt (e/ s)
(if (and e (setq tp (type e))
(atom e)
(or (= tp 'vla-object)
(and (= tp 'ename)(setq e (vlax-ename->vla-object e)))
)
)
(progn
(vla-GetBoundingBox e 'a 'b)
(mapcar 'vlax-safearray->list (list a b));输出左下角和右上角坐标
)
)
)
(setq ss (ssget ":S"(list '(0 . "*line")'(8."E-WIRE-FIRE-CIRC-MCNT,E-WIRE-FIRE,E-WIRE-FIRE-CIRC-BRDT,E-WIRE-FIRE-CIRC-TELP,E-WIRE-MCNT,E-WIRE-消防手动,E-WIRE-CCTR,E-WIRE-FIRE-T+P"))))
(setq zuhelst '(("E-WIRE-CCTR" "WDZN-RYJS-2x1.0-SC16") ("E-WIRE-MCNT" "WDZN-RYJS-2x1.5 -SC16") ("E-WIRE-消防手动" "WDZN-RYJS-2*1.0-SC16+WDZN-RYJS-2*1.5-SC16") ("E-WIRE-FIRE-CIRC-TELP" "WDZNRVVP-2x1.0-SC16") ("E-WIRE-FIRE-CIRC-BRDT" "WDZN-BYJ-2x1.5-SC16") ("E-WIRE-FIRE-T+P" "WDZN-RYJS-2X1.5-SC16+WDZN-BYJ-2X2.5-SC16") ("E-WIRE-FIRE-CIRC-MCNT" "WDZN-RYJS-2X1.5-SC16+WDZN-BYJ-2X2.5-SC16") ("E-WIRE-FIRE" "WDZN-RYJS-2X1.5-SC16")))
(mapcar '(lambda(a)
(setq tc(cdr(assoc 8 (entget a))))
(setq p1(cadr(xj-en2pt a))
p2(polar p1 0 8000)
)
(setq str
(cadr(car(vl-remove-if-not '(lambda(x)(member tc x)) zuhelst)))
)
(entmake (list '(0 . "TEXT")'(41 . 0.35) (cons 1 str)(cons 50 0) (cons 10 p2) (cons 11 p2) (cons 72 0) (cons 73 2) (cons 40 600)))
)
(vl-remove-if-not '(lambda(x)(= 'ENAME (type x))) (mapcar 'cadr (ssnamex ss)))
)
(princ)
)
是根据不同图层和线型来找对应文字? ssyfeng 发表于 2023-8-16 12:36
是根据不同图层和线型来找对应文字?
你好大哥,就是比如消费广播那个线,点击线后 在线上生成文字 WDZN-BYJ-2*1.5-SC16。就是点对应的线后 生成对应的文字 xj6019 发表于 2023-8-16 12:56
没啥好处,纯体力活呀
兄弟你这速度有点快啊:lol xj6019 发表于 2023-8-16 12:56
没啥好处,纯体力活呀
兄弟能不能标注到线的中间 (xj-en2pt a)这个就是两个端点,俩端点算中点,没难度吧,自己搞搞玩吧,简单的还是自己动手一下 xj6019 发表于 2023-8-16 12:56
没啥好处,纯体力活呀
(defun C:NM (/ ss xj-en2pt zuhelst)
(defun xj-en2pt (e/ s)
(if (and e (setq tp (type e))
(atom e)
(or (= tp 'vla-object)
(and (= tp 'ename)(setq e (vlax-ename->vla-object e)))
)
)
(progn
(vla-GetBoundingBox e 'a 'b)
(mapcar 'vlax-safearray->list (list a b));输出左下角和右上角坐标
)
)
)
(setq ss (ssget ":S"(list '(0 . "*line")'(8."E-WIRE-FIRE-CIRC-MCNT,E-WIRE-FIRE,E-WIRE-FIRE-CIRC-BRDT,E-WIRE-FIRE-CIRC-TELP,E-WIRE-MCNT,E-WIRE-消防手动,E-WIRE-CCTR,E-WIRE-FIRE-T+P"))))
(setq zuhelst '(("E-WIRE-CCTR" "WDZN-RYJS-2x1.0-SC16") ("E-WIRE-MCNT" "WDZN-RYJS-2x1.5 -SC16") ("E-WIRE-消防手动" "WDZN-RYJS-2*1.0-SC16+WDZN-RYJS-2*1.5-SC16") ("E-WIRE-FIRE-CIRC-TELP" "WDZNRVVP-2x1.0-SC16") ("E-WIRE-FIRE-CIRC-BRDT" "WDZN-BYJ-2x1.5-SC16") ("E-WIRE-FIRE-T+P" "WDZN-RYJS-2X1.5-SC16+WDZN-BYJ-2X2.5-SC16") ("E-WIRE-FIRE-CIRC-MCNT" "WDZN-RYJS-2X1.5-SC16+WDZN-BYJ-2X2.5-SC16") ("E-WIRE-FIRE" "WDZN-RYJS-2X1.5-SC16")))
(mapcar '(lambda(a / p1 p2 pt pts str tc)
(setq tc(cdr(assoc 8 (entget a))))
(setq pts(xj-en2pt a)
p1(car pts)
p2(cadr pts)
pt(mapcar '(lambda (x y) (* (+ x y) 0.5)) p1 p2)
)
(setq str
(cadr(car(vl-remove-if-not '(lambda(x)(member tc x)) zuhelst)))
)
(entmake (list '(0 . "TEXT")'(41 . 0.35) (cons 1 str)(cons 50 (angle p1 p2)) (cons 10 pt) (cons 11 pt) (cons 72 1) (cons 73 1) (cons 40 300)))
)
(vl-remove-if-not '(lambda(x)(= 'ENAME (type x))) (mapcar 'cadr (ssnamex ss)))
)
(princ)
)
页:
[1]