autocad中用VBA读取块的属性

Sub setAttributes()

'变量声明

Dim modelSpac As AcadModelSpace
Dim objAttributes As Variant
Dim pipeLineValue As Variant
Dim indexValue As String
Dim objNum As Integer

'创建模型空间

Set modelSpac = ThisDrawing.ModelSpace

' 获取实例,并判断需要的实例

For Each ent In modelSpac
    Debug.Print ent.Name
    If TypeOf ent Is AcadBlockReference And ent.HasAttributes() And ent.Name = "管线特性块" Then

        objAttributes = ent.getAttributes
        indexValue = objAttributes(0).TextString

’修改块属性值
        pipeLineValue = getLineValue(indexValue)
        
        If UBound(objAttributes) = UBound(pipeLineValue) Then

            For n = 0 To UBound(objAttributes)
    
                Debug.Print objAttRef.TagString
                objAttributes(n).TextString = pipeLineValue(n)
                
            Next
        Else
            Debug.Print "属性对:数量不一致"
        End If
        
    End If
Next

End Sub

Function getLineValue(LineNo) As String()
Dim LineValue(0 To 3) As String

LineValue(0) = "2"
LineValue(1) = "a"
LineValue(2) = "我的"
LineValue(3) = "ad"
getLineValue = LineValue()

End Function

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值