0 Members and 1 Guest are viewing this topic.
Not the fastest, but give this a try:Code - Auto/Visual Lisp: [Select](defun c:foo (/ a d el l mp p s tmp tx) ;; RJP » 2019-11-13 (cond ((and (setq d (getdist "\nPick a max distance to use: ")) (setq s (ssget '((0 . "circle,text")))) ) (foreach x (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))) (setq p (cdr (assoc 10 (setq el (entget x))))) (if (= "TEXT" (cdr (assoc 0 el))) (setq tx (cons (list p (cdr (assoc 1 el)) (rem (cdr (assoc 50 el)) pi)) tx)) (setq l (cons p l)) ) ) (while (cadr l) (setq p (car l)) (setq l (cdr l)) (foreach p2 l (cond ((<= (distance p p2) d) (setq a (rem (angle p p2) pi)) (setq mp (mapcar '/ (mapcar '+ p p2) '(2 2 2))) (setq tmp nil) (foreach x tx (if (equal (last x) a 1e-3) (setq tmp (cons (cons x (distance (car x) mp)) tmp)) ) ) (and (setq tmp (caar (vl-sort tmp '(lambda (r j) (< (cdr r) (cdr j)))))) (entmakex (list '(0 . "line") (cons 8 (cadr tmp)) (cons 10 p) (cons 11 p2))) (setq tx (vl-remove tmp tx)) (grdraw (car tmp) mp 3) ) ) ) ) ) ) ) (princ))
Are you sure your 4-2 is correct? In the rest of your table all the *-2 are 2M20.Easy to do with consistent logic:Code - Auto/Visual Lisp: [Select]( if (wcmatch txt "*-1") "2M24" "2M20" )Looking closer I don't see a pattern .. research creating an association list then apply the name to the key found (cdr (assoc key lst)).