Jump to content

Problems ActiveSelectionset


AstroNout

Recommended Posts

Hi guys

 

I've been doing some tweaking on my programs, but now i seem to have a problem with my active selectionset. Can I empty it? Because it's a read-only object, and the problem is that I use the active selectionset in my program. It runs just fine the first time, but the second time, it takes the last entity of the last run as the active selectionset.

 

Here's the code:

Sub DErase()
   Dim aEnt As AcadEntity
   Dim aLayer1, aLayer2 As AcadLayer
   Dim aSSet As AcadSelectionSet
   Dim strLayerName  As 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

 

Thanks for the suggestions!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...