AstroNout 发表于 2022-7-6 22:42:33

问题ActiveSelectionset

嗨,伙计们
 
我一直在对我的程序进行一些调整,但现在我的活动选择集似乎有问题。我可以清空它吗?因为它是一个只读对象,问题是我在程序中使用了活动的selectionset。它第一次运行正常,但第二次,它将最后一次运行的最后一个实体作为活动选择集。
 
代码如下:
Sub DErase()
   Dim aEnt As AcadEntity
   Dim aLayer1, aLayer2 As AcadLayer
   Dim aSSet As AcadSelectionSet
   Dim strLayerNameAs String
   
   On Error GoTo Delete
    Set aSSet = ThisDrawing.SelectionSets.Add("sset")
   
   On Error GoTo Continue
   If ThisDrawing.ActiveSelectionSet.Count = 0 Then
   
       aSSet.SelectOnScreen
   

   Else
       Set aSSet = ThisDrawing.ActiveSelectionSet
   
   End If
   
   For Each aEnt In aSSet
         aLayer1 = aEnt.Layer
         strLayerName = "D_" & aLayer1
         Set aLayer2 = ThisDrawing.Layers.Add(strLayerName)
         aEnt.Layer = "D_" & aLayer1
         aEnt.Update
   Next

   ThisDrawing.SelectionSets.Item("sset").Delete
   
   
   Exit Sub
      
Delete:
   ThisDrawing.SelectionSets.Item("sset").Delete
   Exit Sub

Continue:
   Resume Next
End Sub
 
谢谢你的建议!
页: [1]
查看完整版本: 问题ActiveSelectionset