Jump to content

VBA insertion of blocks with fields


BHAus

Recommended Posts

Hi All,

 

I am using VBA to insert multiple (500+) blocks with a field inside that splits the insertion point of the block into a northing and easting.

 

Unfortunately, after all the blocks are inserted and I regen, each block field turns to hashes and AutoCAD states "The object referenced by the field has been erased." if I try to modify it. I can, but manually and it takes ages!

 

This only happens after the first block and the new block insert remains perfect.

 

Has anyone come across this and know how to fix it?

 

BH

Link to comment
Share on other sites

  • 1 year later...

I know it's bad etiquette to bump such an old post, but I ran across this while googling something else. I'm really just answering this for posterity in case someone else runs across it.

 

 

 

 

I have actually gotten this to work quite well using VB.NET. We use a plug in here at work that I created about two years ago for importing and creating CSV files for use with our total stations in the field. While my experience with this is in VB.NET, I suspect it is very similar. When I did this, I used fields for a block's attribute text. When I created block references, I had to add the attribute references for each block reference along with the field. So, when the block was inserted, I had to look at all of the objects in the block's definition, find the attributes in the definition, append attribute references to the block reference attribute collection for each attribute, and set the field for each attribute reference. Even the fields themselves must be added to the drawing database, since AutoCAD has a field list. If the fields (really field references if I understand it right) aren't added, the fields in the block references don't mean anything.

 

 

Try adding a block with fields. Then change the block definition to add an attribute and make its default text a field for its y coordinate. Add the new block. Notice, the older blocks do NOT update with the new field to reflect their y coordinates now. Their block references do not have the field or attribute reference in their attribute collection, and AutoCAD does not automatically add them even though the block definition has been updated. It also doesn't have fields in its field list pertaining to those block references. I'm not sure exactly how the OP was attempting to add these fields, but what it seems like is that he did not add the fields to the drawing database. Since the fields did not exist in AutoCAD's field list, they didn't really exist. Again, when you are doing this, the attribute references and fields must be created and added each time you insert a block reference.

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