Code Red > AutoLISP (Vanilla / Visual)
Replace text with existing block with attribute
ronjonp:
If you still have text near the blocks, THIS could be modified to copy text value into the attribute.
luisternou:
Thanks ronjonp! That looks promising. I will look in to that first thing in the morning!
luisternou:
Hi Ronjonp! I tried the lisp but it not working in my drawing. I attached a small part of it. Maybe you can take a look?
Thanks in advance!
Kind regards,
Luis
ronjonp:
--- Quote from: luisternou on March 24, 2017, 07:27:23 AM ---Hi Ronjonp! I tried the lisp but it not working in my drawing. I attached a small part of it. Maybe you can take a look?
Thanks in advance!
Kind regards,
Luis
--- End quote ---
Here you go:
--- Code - Auto/Visual Lisp: ---(defun c:foo (/ blocks el fuzz p text txt x) (vl-load-com) (setq fuzz 0.001) (if (and (setq text (ssget "_x" '((0 . "text") (8 . "!Kunstwerken_Watervaknummer")))) (setq blocks (ssget "_x" '((0 . "insert") (66 . 1) (2 . "Symbool_Kunstwerk")))) (setq blocks (mapcar 'vlax-ename->vla-object (mapcar 'cadr (ssnamex blocks)))) (setq text (mapcar '(lambda (x) (setq el (entget x)) (list (cdr (assoc 11 el)) (cdr (assoc 1 el)) x)) (mapcar 'cadr (ssnamex text)) ) ) ) (foreach block blocks (setq p (vlax-get block 'insertionpoint)) (if (setq txt (vl-some '(lambda (x) (if (equal p (car x) fuzz) x ) ) text ) ) (progn (mapcar '(lambda (x) (vla-put-textstring x (cadr txt))) (vlax-invoke block 'getattributes) ) (entdel (last txt)) ) ) ) ) (princ))
luisternou:
Hello again Ronjonp!
For you it is maybe nothing but for me this is amazing :yay!: :yay!: :yay!: Thank you very much!! :-D
In the meantime I was also examining this routine. It did something but not as smooth and fast as your routine. Maybe it is interesting for you to study.
http://cadtips.cadalyst.com/attributed-blocks/automatically-convert-text-or-mtext-attributes (credits to Ricky Medley).
Anyway, thangs again! I am glad I get my deadline in time! :-D
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version