Skrejz Posted January 27, 2019 Posted January 27, 2019 Hello, In this DWG i need to pair text (which is room function) with block attribute "FUNCTION" that i've created. I can do this manually but it's over 1000 blocks ,so that make me wonder is it possible to create LISP which take nearest text into block attribute. I've found that LISP (https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/add-text-value-to-a-block-attibute/td-p/7949545) but it's swaping texts over rooms for example in room where laboratorium is located it name it biuro which is located next to it. Sorry for my plain english, I'm not native speaker. Thanks in advance! test_1.dwg Quote
rlx Posted January 27, 2019 Posted January 27, 2019 (edited) not sure if effectively you're asking for the text to be replaced with your block but if so , you can try this (defun c:t1 ( / wai a ss n ba bi bo c to s) (defun wai (b n v) (vl-some '(lambda (x)(if (= (strcase n)(strcase (vla-get-tagstring x))) (progn(vl-catch-all-apply 'vlax-put-property (list x 'MTextAttribute -1))(vla-put-textstring x v)))) (vlax-invoke b 'getattributes)) ) (setq a (vla-get-activedocument (vlax-get-acad-object)) c 1 n "Block_1" ba "Function") (if (and (setq ss (ssget "x" '((0 . "TEXT,MTEXT"))))(setq ss (vla-get-activeselectionset a))(tblsearch "block" n)) (vlax-for to ss (setq bi (vla-get-insertionpoint to) s (vla-get-textstring to)) (vla-delete to)(setq bo (vla-insertblock (vla-get-ModelSpace a) bi n c c c 0))(wai bo ba s))) (if ss (vl-catch-all-apply 'vlax-release-object (list ss))) (vla-regen a acActiveViewport) (princ) ) Edited January 27, 2019 by rlx Quote
Skrejz Posted January 28, 2019 Author Posted January 28, 2019 Thank you rlx! It's exactly what i wanted. Quote
rlx Posted January 28, 2019 Posted January 28, 2019 24 minutes ago, Skrejz said: Thank you rlx! It's exactly what i wanted. glad to hear Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.