Sub tcDel() '删除实体所在图层 On Error Resume Next '删除图层中的对象 Dim objDest As AcadEntity Dim ptBase As Variant Dim FilterType As Variant Dim FilterData As Variant Dim Sel As AcadSelectionSet Dim Fdata(0) As Variant Dim Ftype(0) As Integer Dim Pickedobj As AcadEntity Dim VByn As String Dim TcName As String Do ThisDrawing.Utility.GetEntity objDest, ptBase, "选择所删除图层中的实体>>" If objDest.ObjectName = "" Then VByn = MsgBox("请重新选择图层", 5, "删除图层") If VByn <> "4" Then Exit Sub End If Else Exit Do End If Loop Ftype(0) = 8 Fdata(0) = objDest.Layer FilterType = Ftype FilterData = Fdata TcName = objDest.Layer If ThisDrawing.Layers(TcName).Lock = True Then VByn = MsgBox("该图层已锁定,删除", 4, "删除图层") If VByn = "6" Then ThisDrawing.Layers(TcName).Lock = False '解锁 Else Exit Sub End If End If Set Sel = ThisDrawing.SelectionSets.Add("ssel") If Err Then Err.Clear ThisDrawing.SelectionSets("ssel").Delete Set Sel = ThisDrawing.SelectionSets.Add("ssel") End If Sel.Select acSelectionSetAll, , , FilterType, FilterData For Each Pickedobj In Sel Pickedobj.Delete Next End Sub
|