如何选择框选范围内带有属性的文字
如何选择这些带有属性的文字,采用框选法选择后将带有属性的文字选择出来 带属性的文字是不是就是属性块?可以用select+选择集过滤器选择,然后用GetAttributes方法获得属性块里的文字属性。 yanyanjun999 发表于 2011-2-9 21:52 static/image/common/back.gif带属性的文字是不是就是属性块?可以用select+选择集过滤器选择,然后用GetAttributes方法获得属性块里的文 ...
请问GetAttributes的方法是怎样操作,没有使用过?
谢谢 给你个cad帮助里面的例子
本例创建一个块,然后向块中添加属性。接着将块插入到图形中。然后返回属性数据,并在消息框中显示。块参照中的属性数据将被更新,并再次返回和显示属性数据。
Sub Ch10_GettingAttributes()
' 创建块
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")
' 定义属性定义
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"
' 在块上创建属性定义对象
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, "TESTBLOCK", 1, 1, 1, 0)
ZoomAll
' 获取块参照的属性
Dim varAttributes As Variant
varAttributes = blockRefObj.GetAttributes
' 将属性标记和值移至
' 要在 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
' 更改属性值
' 注意:没有 SetAttributes。一旦包含
' 变量数组,就拥有了对象。
' 更改这些对象就会改变图形中的对象。
varAttributes(0).textString = "NEW VALUE!"
' 再次获取属性
Dim newvarAttributes As Variant
newvarAttributes = blockRefObj.GetAttributes
' 再次显示标记和值
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
就是如图所示建立的文字, 这些文字如何与普通的文字区别 回复 yanyanjun999 的帖子
谢谢
收藏了,下来慢慢看,学习领会领会。
页:
[1]