可以使用 Attribute 对象特性和方法来编辑属性。属性上的部分特性如下:
- Alignment
- Backward
- FieldLength
- Height
- InsertionPoint
- Mode
- PromptString
- Rotation
- ScaleFactor
- TagString
本例创建一个块,然后向块中添加属性。接着将块插入到图形中。然后更新属性文字,使其反向显示。
Sub Ch10_RedefiningAnAttribute()
' 定义块
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, "BlockWithAttribute")
' 向块添加属性
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 = "New Prompt"
insertionPoint(0) = 5
insertionPoint(1) = 5
insertionPoint(2) = 0
tag = "New Tag"
value = "New Value"
Set attributeObj = blockObj.AddAttribute(height, mode, _
prompt, insertionPoint, tag, value)
' 插入块,创建块参照
' 和属性参照
Dim blockRefObj As AcadBlockReference
insertionPnt(0) = 2
insertionPnt(1) = 2
insertionPnt(2) = 0
Set blockRefObj = ThisDrawing.ModelSpace.InsertBlock _
(insertionPnt, "BlockWithAttribute", 1#, 1#, 1#, 0)
' 重定义属性文字,使其反向显示。
attributeObj.Backward = True
attributeObj.Update
End Sub