Jump to content

VBA - Updating changes made to Attributes


harilalmn

Recommended Posts

I have created a vba macro to edit attributes in Blocks. I tried so many times but it doesn't update the attributes in drawing, unless I manually do a BATTMAN...

What is wrong?

Link to comment
Share on other sites

I think this situation is typically addressed by calling ATTSYNC via ThisDrawing.SendCommand. As distasteful as it may be to use SendCommand, it works fairly well if the call is made at the end of the routine.

 

The other, more laborious option would be to interrogate all the attributes, store the information, delete then recreate everything from scratch. This should allow the expected performance out of the .Update method.

Link to comment
Share on other sites

maybe this will help

 

Set SS = ThisDrawing.SelectionSets.Add("issued")
SS.Select acSelectionSetAll, , , FilterDXFCode, FilterDXFVal

For Cntr = 0 To SS.Count - 1
  attribs = SS.Item(Cntr).GetAttributes
       
       
       attribs(0).TextString = "ISSUED FOR CONSTRUCTION"
       attribs(3).TextString = "0"
       
       attribs(0).Update
       attribs(3).Update
       
Next Cntr

Link to comment
Share on other sites

BIGAL and SEANT,

Thanks a lot for your replies...

I had some error coming up regarding FilterDXFCode. However, ATTSYNC worked for me. Thanks both of you...

Link to comment
Share on other sites

Yeah left this stuff out which you will need

 

Dim FilterDXFCode(1) As Integer
Dim FilterDXFVal(1) As Variant
Dim attribs As Variant
Dim BLOCK_NAME As String
On Error Resume Next
FilterDXFCode(0) = 0
FilterDXFVal(0) = "INSERT"
FilterDXFCode(1) = 2
FilterDXFVal(1) = "DA1DRTXT"
BLOCK_NAME = "DA1DRTXT"

Link to comment
Share on other sites

This thread prompted me to look back at some old VBA code and see that I had missed the Attribute.Update method. The code is pretty old, though (circa AutoCAD 2000) which may have had other issues.

It’s too bad that I find out about it now, when I’ve abandoned any new VBA coding.

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