以下是借用坛里大神的代码,在此感谢;
我想删除很多同名块中的指定颜色和指定文字,请大神高抬贵手;- Sub Example_Select()
- On Error Resume Next
- Dim ssetObj As AcadSelectionSet
- Set ssetObj = ThisDrawing.SelectionSets.Add("sset")
- If Err Then
- Err.Clear
-
- Set ssetObj = ThisDrawing.SelectionSets.Item("sset")
- End If
- ssetObj.Clear
-
- Dim mode As Integer
- Dim gpCode(0) As Integer
- Dim dataValue(0) As Variant
-
- gpCode(0) = 0
- dataValue(0) = "insert"
-
- Dim groupCode As Variant, dataCode As Variant
- groupCode = gpCode
- dataCode = dataValue
-
- ssetObj.Select acSelectionSetAll, , , groupCode, dataCode
- Dim i As Integer
- Dim blkobj As AcadBlock, blkn As String
- For i = 0 To ssetObj.Count - 1
- Set blkobj = ThisDrawing.Blocks(ssetObj.Item(i).Name)
- Ltoc blkobj
- Next
- ThisDrawing.Regen acActiveViewport
- End Sub
- Sub Ltoc(blk As AcadBlock)
- Dim Sube As AcadEntity
- For Each Sube In blk
- Dim tekla As AcadText
-
- If Sube.ObjectName = "AcDbBlockReference" Then
- Ltoc ThisDrawing.Blocks(Sube.Name)
- ElseIf Sube.ObjectName = "AcDbText" Then
- Sube.Delete
- End If
- Next
- End Sub
|