参数标签无效

时间:2016-02-24 08:47:58

标签: vba autocad

我正在Autocad中进行块插入的自定义。设置属性时,我的程序中出现错误:

“设置TagString中的参数Tag无效”

代码如下:

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

什么会导致此错误?

1 个答案:

答案 0 :(得分:2)

嗯,错误信息非常明确,你在设置TagString时有一个“无效的参数标记”

所以简单地删除标签值中的空格,你应该好好去。它不支持空格。

tag = "Attribute Tag" 'BAD
tag = "AttributeTag" 'OK