Hello all. I need a bit of help in understanding some code and getting it to work between excel and AutoCAD. Object is to replace values of attributes in an AutoCAD template with information from cells in a spreadsheet. We have templates and an excel program that will open, fill in a single block instance and save the drawing then go on to next template. We need to be able to fill in the attributes of a block that is in the template 8, 16 or 32 times depending on how many channels are used I a specific template. Values would be different so could use an if statement to identify attribute value to change. Something like
If value = channel1 then
Swap channel1 for B2
End if<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o> (something like that )</o>
Code below was given to me as a start but don’t understand how it would work and when I tried to run I got a compile error on the third line.
“If TypeOf b Is AcadBlockReference Then”.
Don’t see how you can pull a cell value into an attribute with this. Below is all the code i was given.
>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.TagString = "TAG1" Then
> If a.TextString = "VALUE" Then
> a.TextString = "NEW_VALUE"
> End If
> End If
> Next n
> End If
>Next b
<o> </o>
Any help with this would be appreciated.
If value = channel1 then
Swap channel1 for B2
End if<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o> (something like that )</o>
Code below was given to me as a start but don’t understand how it would work and when I tried to run I got a compile error on the third line.
“If TypeOf b Is AcadBlockReference Then”.
Don’t see how you can pull a cell value into an attribute with this. Below is all the code i was given.
>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.TagString = "TAG1" Then
> If a.TextString = "VALUE" Then
> a.TextString = "NEW_VALUE"
> End If
> End If
> Next n
> End If
>Next b
<o> </o>
Any help with this would be appreciated.