开心无惧
发表于 2024-8-31 13:03:53
非常感谢分享
儒门小客
发表于 2024-9-18 23:41:46
非常感谢分享,局部修改可以实现天正文字连线
xyp1964
发表于 2024-9-20 14:07:03
本帖最后由 xyp1964 于 2024-9-20 14:08 编辑
(defun c:tt ()
"相同文字连线"
(defun Ep5 (e / p1 p9 p)
(vla-getboundingbox (vlax-Ename->Vla-Object e) 'p1 'p9)
(setq p(mapcar 'vlax-safearray->list (list p1 p9)))
(mapcar '(lambda (x y) (/ (+ x y) 2.0))(car p)(cadr p))
)
(defun ss2list (ss)
(vl-remove-if'(lambda (x) (/= (type x) 'ENAME))(mapcar 'cadr (ssnamex ss)))
)
(if (and (setq ss1 (ssget ":e:s" '((0 . "TEXT"))))
(setq s1 (ssname ss1 0))
(setq tx (cdr (assoc 1 (entget s1))))
(setq ss (ssget (list '(0 . "TEXT") (cons 1 tx))))
)
(progn
(command "-layer" "m" "文字连线" "c" "6" "" "")
(setq p0(Ep5 s1)
lst (vl-remove s1 (ss2list ss))
)
(foreach x lst (command "line" "non" p0 "non" (Ep5 x) ""))
(princ "\n相同文本数量 = ")
(princ (length lst))
(alert (strcat "\n相同文本数量 = "(itoa (length lst))))
)
)
(princ)
)