Jump to content

Recommended Posts

Posted

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

Posted (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 by rlx
Posted

Thank you rlx! It's exactly what i wanted.

Posted
24 minutes ago, Skrejz said:

Thank you rlx! It's exactly what i wanted.

glad to hear 🐉

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...