Jump to content

VBA - Attributes using old tag when exploded


EGoldberg

Recommended Posts

I am trying to finish up my program in VBA and I have one final problem.

 

When I update a block's attribute tag (not text) because we have two attributes with the same tag name and they need to be redefined, I can update it but as soon as it is exploded it goes back to the old name.

 

That is, I've updated the tag successfully, I can see that I have in properties and the Enhanced Attribute Editor, but when I use -battman, it still says the old tag and when I use explode, it goes from my new tag name to the old. Is there anyway to sync this up in VBA?

 

The code for editing my tag is as follows

 

attList = blk.GetAttributes
attList(3).TagString = "ASB2"
attList(3).Update

 

What am I missing? I'm not much of an AutoCAD user so I'm not sure. Thanks for your help in advance.

Link to comment
Share on other sites

Is there any way to access the block table in VBA? If you do not know about VBA what about LISP? Is there a particular definition that is accessed to alter the data via a programming language?

Link to comment
Share on other sites

in LISP it would be:

 

(vlax-for SubObj (vla-item
                  (vla-get-Blocks
                    (vla-get-ActiveDocument
                      (vlax-get-acad-object)
                    )
                  )
                  "BlockName"
                )
 ...

)

Link to comment
Share on other sites

Lee, thank you so much. I was able to translate the LISP heirarchy to VBA and figure it out. For those who might run into the same problem, to step through the blocks rather than their references, see the following code.

 

For Each ent In ThisDrawing.Blocks
If TypeOf ent Is AcadBlock Then
...
end if
next

Link to comment
Share on other sites

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