我能得到的最接近的是。。。。。。。。。
- (defun C:demo (/ ss i pl_list mt_list mtpt_list sn a b c d e f g h tmp _nearest thelenght)
- (setq _relist (lambda (m)
- ((if m vl-remove-if vl-remove-if-not) '(lambda (x)
- (equal (car f) (car x))) g)))
- (if (setq ss (ssget
- '((410 . "Model")(8 . "0gas")
- (-4 . "<OR")
- (-4 . "<AND")(0 . "MTEXT")(1 . "#****")
- (-4 . "AND>") (0 . "LWPOLYLINE") (-4 . "OR>")))
- )
- (progn
- (repeat (setq i (sslength ss))
- (setq sn (ssname ss (setq i (1- i))))
-
- (if (eq (cdr (assoc 0 (setq ent (entget sn)))) "LWPOLYLINE")
- (setq pl_list (cons (list (vlax-curve-getDistAtParam sn
- (vlax-curve-getendparam sn)) sn ) pl_list))
- (setq mt_list (cons (list (cdr (assoc 10 ent)) (cdr (assoc 1 ent))) mt_list))
- )
- )
- (while (and (setq a (car mt_list)) pl_list)
- (setq tmp (mapcar '(lambda (c)
- (list c (distance (car a)
- (vlax-curve-getClosestPointTo (cadr c) (car a)))
- (car c) (cadr a))) pl_list))
- (setq _nearest (car (vl-sort tmp '(lambda ( d e )
- (< (cadr d) (cadr e)))))
-
- pl_list (vl-remove (Car _nearest) pl_list)
- mtpt_list (cons (list (cadddr _nearest) (caddr _nearest)) mtpt_list)
- mt_list (cdr mt_list))
- )
-
- (setq mtpt_list (vl-sort mtpt_list
- '(lambda (u v)
- (< (car u) (car v))
- )
- )
-
- )
- (while (setq f (car mtpt_list))
- (setq g (cdr mtpt_list))
- (setq thelenght (rtos
- (if (setq h (_relist nil))
- (progn
- (setq g (_relist t))
- (apply '+ (mapcar 'cadr (cons f h))))
- (cadr f)) 2 2 ))
- (princ (strcat "\nThere are "
- (itoa (if h (1+ (length h)) 1))
- " MTEXT objects with content ""
- (car f)
- "" on the current tab and the "
- (if h "total " "")
- "length is " thelenght "m."))
- (setq mtpt_list g)
- )
- )
- )
- (princ)
- )
我尝试了一些东西,但我必须承认我是一个初学者,所以我有点挣扎!
我所能做的就是替换(-4)。”
现在,它列出了每个场景,但它们是单独列出的。
我的代码如下所示。。。。
当前选项卡上有1个多行文字对象,其内容为“63 Pe”
长度为11.93m。
当前选项卡上有1个多行文字对象,其内容为“63mm Pe”
长度为2.44m。
理想情况下,我希望它能做到这一点,但将它们列为每个直径的总数。 |