Jump to content

VBA - Attributes using old tag when exploded


Recommended Posts

Posted

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.

Posted

When exploding / syncing, the block definition as found in the block table will be used I believe.

Posted

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?

Posted

Yes, just use the item method on the blocks collection and then you can iterate through the objects that make up the block. :)

Posted

in LISP it would be:

 

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

)

Posted

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

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