3

I am doing some customization of block insertion in Autocad. When setting up the attributes, I am getting an error in my procedure:

"Invalid argument Tag in setting TagString"

The code is as follows:

Sub Ch10_GettingAttributes()
 ' Create the block
 Dim blockObj As AcadBlock
 Dim insertionPnt(0 To 2) As Double
 insertionPnt(0) = 0
 insertionPnt(1) = 0
 insertionPnt(2) = 0
 Set blockObj = ThisDrawing.Blocks.Add _
 (insertionPnt, "TESTBLOCK")

 ' Define the attribute definition
 Dim attributeObj As AcadAttribute
 Dim height As Double
 Dim mode As Long
 Dim prompt As String
 Dim insertionPoint(0 To 2) As Double
 Dim tag As String
 Dim value As String
 height = 1#
 mode = acAttributeModeVerify
 prompt = "Attribute Prompt"
 insertionPoint(0) = 5
 insertionPoint(1) = 5
 insertionPoint(2) = 0
 tag = "Attribute Tag"
 value = "Attribute Value"

 ' Create the attribute definition object on the block
 Set attributeObj = blockObj.AddAttribute(height, mode,_
prompt, insertionPoint, tag, value)

 End Sub

What would cause this error?

tmccar
  • 85
  • 11

1 Answers1

2

Well, the error message is rather explicit, you have an "Invalid argument Tag in setting TagString"

So simply get rid of space in the tag value and you should be good to go. It doesn't support spaces.

tag = "Attribute Tag" 'BAD
tag = "AttributeTag" 'OK
Felipe
  • 4,325
  • 1
  • 14
  • 19