Sub QSelLayerControl() '程序功能:快速选取一层的所有对象,进行相应的操作 Dim i As AcadEntity Dim ss As AcadSelectionSet Dim ft(0) As Integer, fd(0) Dim pLayer As String Dim pControl As String pLayer = ThisDrawing.Utility.GetString(0, vbCrlLf & "请输入层名:") ft(0) = 8: fd(0) = pLayer Set ss = ThisDrawing.ActiveSelectionSet ss.Clear ss.Select acSelectionSetAll, , , ft, fd If ss.Count = 0 Then ss.Delete ThisDrawing.Utility.Prompt "层内没有对象或层不存在!" Else ThisDrawing.Utility.InitializeUserInput 1, "Move Copy Erase" pControl = ThisDrawing.Utility.GetKeyword(vbCr & "请输入操作名[Move(移动)/Copy(复制)/Erase(删除)]:") ThisDrawing.SendCommand "." & pControl & vbCr & "p" & vbCr & vbCr End If '附:将下列代码Copy到acad200?doc.lsp中,执行命令QSLC ' (defun C:QSLC() ' (setvar "cmdecho" 0) ' (command "-vbarun" "qsellayercontrol") ' (setvar "cmdecho" 1) ' (princ) ' ) End Sub
修改以下看看
Sub qselect() Dim tsel As AcadSelectionSet Dim entry As AcadEntity Dim tpic As Variant Dim layerstr As String On Error Resume Next Set tsel = ThisDrawing.SelectionSets("topirolss") If Err Then Err.Clear Set tsel = ThisDrawing.SelectionSets.Add("topirolss") tsel.Clear End If ThisDrawing.Utility.GetEntity entry, tpic, "选择实体:"
If Err Then Err.Clear Exit Sub End If layerstr = entry.Layer Dim FilterType(0) As Integer Dim FilterData(0) As Variant FilterType(0) = 8 FilterData(0) = layerstr tsel.Select acSelectionSetAll, , , FilterType, FilterData tsel.Highlight (True) If tsel.Count = 0 Then tsel.Delete Else ThisDrawing.Utility.InitializeUserInput 1, "Move Copy Erase" pControl = ThisDrawing.Utility.GetKeyword(vbCr & "请输入操作名[Move(移动)/Copy(复制)/Erase(删除)]:") ThisDrawing.SendCommand "." & pc & vbCr & "p" & vbCr & vbCr End If End Sub