Public Sub dq() Dim ssetobj1 As AcadSelectionSet Dim icount1 As Integer icount1 = ThisDrawing.SelectionSets.Count While (icount1 > 0) If ThisDrawing.SelectionSets.Item(icount1 - 1).Name = "yuan" Then ThisDrawing.SelectionSets.Item(icount1 - 1).Delete End If icount1 = icount1 - 1 Wend Set ssetobj1 = ThisDrawing.SelectionSets.Add("yuan") ThisDrawing.Utility.Prompt "please select object" ssetobj1.SelectOnScreen Dim i1 As Integer Dim selobj1 As AcadEntity On Error Resume Next Set selobj1 = ssetobj1.Item(i1)
Dim str As String str = selobj1.Layer ThisDrawing.ActiveLayer = str
Dim str As String str = selobj1.layer Dim layer As AcadLayer For Each layer In ThisDrawing.Layers If layer.Name = str Then ThisDrawing.ActiveLayer = layer Next