土木在线论坛 \ 商易宝社区 \ 行业脉动 \ 编译通不过cad自带例子

编译通不过cad自带例子

发布于:2008-04-19 08:59:19 来自:商易宝社区/行业脉动 [复制转发]
编译通不过Ch10_GettingAttributes()


Dim varAttributes As Variant
varAttributes = blockRefObj.GetAttributes

’ Move the attribute tags and values into a
’ string to be displayed in a Msgbox
Dim strAttributes As String
strAttributes = ""
Dim I As Integer
For I = LBound(varAttributes) To UBound(varAttributes)
strAttributes = strAttributes + " Tag: " + _
varAttributes(I).TagString + vbCrLf + _
" Value: " + varAttributes(I).TextString
Next

varAttributes(I).TagString 提示 runtime error automation error library not registerd
以下为全部源代码
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)


’ Insert the block
Dim blockRefObj As AcadBlockReference
insertionPnt(0) = 2
insertionPnt(1) = 2
insertionPnt(2) = 0
Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock _
(insertionPnt, "TESTBLOCK", 1, 1, 1, 0)
ZoomAll

’ Get the attributes for the block reference
Dim varAttributes As Variant
varAttributes = blockRefObj.GetAttributes

’ Move the attribute tags and values into a
’ string to be displayed in a Msgbox
Dim strAttributes As String
strAttributes = ""
Dim I As Integer
For I = LBound(varAttributes) To UBound(varAttributes)
strAttributes = strAttributes + " Tag: " + _
varAttributes(I).TagString + vbCrLf + _
" Value: " + varAttributes(I).TextString
Next
MsgBox "The attributes for blockReference " + _
blockRefObj.Name & " are: " & vbCrLf _
& strAttributes

’ Change the value of the attribute
’ Note: There is no SetAttributes. Once you have the
’ variant array, you have the objects.
’ Changing them changes the objects in the drawing.
varAttributes(0).TextString = "NEW VALUE!"

’ Get the attributes again
Dim newvarAttributes As Variant
newvarAttributes = blockRefObj.GetAttributes

’ Again, display the tags and values
strAttributes = ""
For I = LBound(varAttributes) To UBound(varAttributes)
strAttributes = strAttributes + " Tag: " + _
newvarAttributes(I).TagString + vbCrLf + _
" Value: " + newvarAttributes(I).TextString
Next
MsgBox "The attributes for blockReference " & _
blockRefObj.Name & " are: " & vbCrLf _
& strAttributes
End Sub
  • tongmingniao
    tongmingniao 沙发
    我用cad2006能够通过该示例,楼主可找一下其他原因。
    2009-03-16 19:27:16

    回复 举报
    赞同0
这个家伙什么也没有留下。。。

行业脉动

返回版块

12.06 万条内容 · 86 人订阅

猜你喜欢

阅读下一篇

建筑施工员在工地上应该做些什么

建筑施工员在工地上应该做些什么http://co.163.com/if_40931454_3.htm

回帖成功

经验值 +10