- 积分
- 73549
- 明经币
- 个
- 注册时间
- 2001-6-7
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2003-7-13 19:08:00
|
显示全部楼层
- Sub DelBlkByName()
- Dim BlockName As String
- BlockName = "11" '这里保存着要删除的图块名称
- Dim ss As AcadSelectionSet
- Set ss = CreateSelectionSet()
- Dim fType As Variant
- Dim fDate As Variant
- BuildFilter fType, fData, 0, "INSERT", 2, BlockName
- ss.Select acSelectionSetAll, , , fType, fData
- Dim Ent As AcadEntity
- Dim i As Integer
- i = ss.Count
- If i > 0 Then
- For Each Ent In ss
- Ent.Delete
- Next
- Update
- MsgBox "图形中共有" & i & "个名称为“" & BlockName & "”的图块,都已经被删除了。", , _
- "明经通道VBA示例"
- Else
- MsgBox "图形中没有名称为“" & BlockName & "”的图块存在。", , _
- "明经通道VBA示例"
- End If
- End Sub
- Public Function CreateSelectionSet(Optional ssName As String = "ss") As AcadSelectionSet
- Dim ss As AcadSelectionSet
-
- On Error Resume Next
- Set ss = ThisDrawing.SelectionSets(ssName)
- If Err Then Set ss = ThisDrawing.SelectionSets.Add(ssName)
- ss.Clear
- Set CreateSelectionSet = ss
- End Function
- Public Sub BuildFilter(typeArray, dataArray, ParamArray gCodes())
- Dim fType() As Integer, fData()
- Dim index As Long, i As Long
-
- index = LBound(gCodes) - 1
-
- For i = LBound(gCodes) To UBound(gCodes) Step 2
- index = index + 1
- ReDim Preserve fType(0 To index)
- ReDim Preserve fData(0 To index)
- fType(index) = CInt(gCodes(i))
- fData(index) = gCodes(i + 1)
- Next
- typeArray = fType: dataArray = fData
- End Sub
|
|