Jump to content

Recommended Posts

Posted (edited)

Hi everyone,

I’m trying to get the text from an Attribute Definition (ATTDEF) inside a dynamic block using AutoLISP, and then change that text. Unfortunately, I haven’t been able to make it work.

Here is what I tried:

(defun getblockentities (blk / ent enx rtn)
  (if (setq ent (tblobjname "block" blk))
    (while (setq ent (entnext ent))
      (setq enx (entget ent))
      (if (= "INSERT" (cdr (assoc 0 enx)))
        (getblockentities (cdr (assoc 2 enx)))
        (progn
          (setq text (vlax-ename->vla-object ent))
          (if (car text)
            (setq tlist (append tlist (list text)))
          )
        )
      )
    )
  )
)

And then I tried to collect attributes like this:
 

(setq attlist (vlax-invoke textObj 'GetAttributes))
(foreach att attlist
  (if (not (eq (vla-get-tagstring att) nil))
    (progn
      (setq text (vla-get-tagstring att))
      (setq tlist (append tlist (list text)))
    )
  )
)

But with this approach I couldn’t retrieve the attribute text. Is there another method to get (and later modify) the text string of an attribute inside a dynamic block?

Thanks in advance for any guidance.

edit: ı'm adding to dwg for trydinamic block text.dwg

Edited by p7q
Posted

Hi @p7q,

 

You can try with this several options from image below.

 

image.thumb.png.e60a47417b9158887b2b1b8a265023f4.png

 

From the last lines of code, you will get something like this.

 

image.png.b1b1c35273ecfede103d913187ab0cf6.png

 

Try to play with this. Also, you can get from Lee Mac website about Attribute Functions.

 

Best regards.

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...