VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Changing an Attribute value with If statement

1 REPLY 1
Reply
Message 1 of 2
mmckenzie
276 Views, 1 Reply

Changing an Attribute value with If statement

I'm trying to do a search and replace of an attribute value. I have template drawings with multiple occurances of the same attribute "TAG1". I'm trying to write an If statement that will update the value of the attribute based on it's current value. What I'm not sure how to do is how to get VB to read the value. I'm far from a VB expert so any help would be appreciated.

Here's what I'm trying to do in english.

If the value of TAG1 is = to CR1 Then. Not sure how to do this.

Replace with a value from a cell in Excel. I've got this part down.

Thanks in advance.

Mark
1 REPLY 1
Message 2 of 2
st0neface
in reply to: mmckenzie

maybe this helps you getting started

{code}

Dim a, b, n
For Each b In ThisDrawing.ModelSpace
If TypeOf b Is AcadBlockReference Then
a = b.GetAttributes
For n = 0 To UBound(a)
If a(n).TagString = "TAG1" Then
If a(n).TextString = "VALUE" Then
a(n).TextString = "NEW_VALUE"
End If
End If
Next n
End If
Next b


{code}

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost