- 积分
- 289
- 明经币
- 个
- 注册时间
- 2018-4-8
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
楼主 |
发表于 2020-6-19 14:08:44
|
显示全部楼层
与上一个帖子同样的功能,用VBA实现
- 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
|
|