首页 > 编程语言 > 详细

使用VBA在CAD中删除选中对象中的文字和标注

时间:2020-03-15 00:33:02      阅读:385      评论:0      收藏:0      [点我收藏+]
代码如下
 
Sub deleteTextAndDimension()
    
    Dim oSS As Object
    On Error Resume Next
    If Not IsNull(ThisDrawing.SelectionSets.Item("Wolf")) Then
        Set oSS = ThisDrawing.SelectionSets.Item("wolf")
        oSS.Delete
    End If
    Set oSS = ThisDrawing.SelectionSets.Add("wolf")

    On Error GoTo catchError
    Dim fType() As Integer
    Dim fData As Variant
      strFilterType = "-4,0,0,-4"
    strFilterData = "<or,text,dimension,or>"
    Call createFilter(fType, fData, strFilterType, strFilterData)

    oSS.SelectOnScreen fType, fData
    oSS.Highlight ture
    oSS.Erase
    oSS.Delete

exitSub:
    Exit Sub
catchError:
    ‘ add error handling
    If Err Then
        Err.Clear
        MsgBox Err.Description
    End If
    
End Sub

Sub createFilter(fType, fData, strFilterType, strFilterData)
    ‘// add declarations
    On Error GoTo catchError
    arrFilterType = Split(strFilterType, ",")
    arrFilterData = Split(strFilterData, ",")
    If UBound(arrFilterType) = UBound(arrFilterData) Then
        intFilterCount = UBound(arrFilterType)
        ReDim fType(intFilterCount)
        ReDim fData(intFilterCount)
        For i = 0 To UBound(arrFilterType)
            fType(i) = arrFilterType(i)
            fData(i) = arrFilterData(i)
        Next i
    Else
        GoTo exitFunction
    End If

exitFunction:
    Exit Sub
catchError:
    ‘// add error handling
    GoTo exitFunction
End Sub

使用VBA在CAD中删除选中对象中的文字和标注

原文:https://www.cnblogs.com/dogingate/p/12495209.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!