Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Erasing a selection set name

  1. #1
    All AUGI, all the time
    Join Date
    2003-10
    Posts
    706
    Login to Give a bone
    0

    Default Erasing a selection set name

    Here's a quicky. How do you release or erase a selection set once it is created? I want to use:

    Set sset = ThisDrawing.SelectionSets.Add("ss1")

    where ss1 is the name of the selection set but after the objects are used I want the user to be able to select another selection set with the same name to keep working but an error keeps coming up stating the selection set (ss1) already exists. Help!

  2. #2
    Member
    Join Date
    2002-02
    Location
    Saskatoon, SK Canada
    Posts
    23
    Login to Give a bone
    0

    Default Re: Erasing a selection set name

    Hi williams.60073.

    When you are done with the selectionset just call:

    sset.Delete

    Or, if you've lost the reference to sset call:

    ThisDrawing.Selectionsets("ss1").Delete

    Hope this helps
    Warren M

  3. #3
    All AUGI, all the time
    Join Date
    2003-10
    Posts
    706
    Login to Give a bone
    0

    Default Re: Erasing a selection set name

    The help file suggests that everything in the selection set will also be deleted if I do that. Is that true?

    From the help file:
    "The Delete method deletes a selection set and all items in the selection set. Neither the selection set, nor the items previously in the selection set will exist after a call to the Delete method."

  4. #4
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,397
    Login to Give a bone
    0

    Default Re: Erasing a selection set name

    You don't have to worry about getting rid of ss's, they're only temporary in the dwg. When you close the dwg, the ss collection is cleared. All you have to worry about is when creating a new one, you don't try to use a name that already exists or you'll get an error. The usual method of avoiding runtime errors is to error trap. Try to create the set with the name you want. If it errors, reuse the name.

    Code:
    Public Function AddSelectionSet1(SetName As String) As AcadSelectionSet
    ' This routine does the error trapping neccessary for creating selection sets.
        On Error Resume Next
        Set AddSelectionSet = ThisDrawing.SelectionSets.Add(SetName)
        If Err.Number <> 0 Then
            Set AddSelectionSet = ThisDrawing.SelectionSets.Item(SetName)
        End If
    End Function
    Once you have the ss, use ss.Clear to start fresh.
    C:> ED WORKING....

  5. #5
    Member
    Join Date
    2002-02
    Location
    Saskatoon, SK Canada
    Posts
    23
    Login to Give a bone
    0

    Default Re: Erasing a selection set name

    From the AutoCAD ActiveX and VBA Reference for 2005:
    "Delete: The Delete method deletes a selection set object, but not the objects in the selection set. While the selection set itself will not exist after the call to the Delete method, the items previously in the selection set will still exist. "

    Warren M

    Quote Originally Posted by williams.60073
    The help file suggests that everything in the selection set will also be deleted if I do that. Is that true?

    From the help file:
    "The Delete method deletes a selection set and all items in the selection set. Neither the selection set, nor the items previously in the selection set will exist after a call to the Delete method."

  6. #6
    Member
    Join Date
    2004-06
    Posts
    42
    Login to Give a bone
    0

    Default Re: Erasing a selection set name

    Quote Originally Posted by eljobe
    You don't have to worry about getting rid of ss's, they're only temporary in the dwg. When you close the dwg, the ss collection is cleared. All you have to worry about is when creating a new one, you don't try to use a name that already exists or you'll get an error. The usual method of avoiding runtime errors is to error trap. Try to create the set with the name you want. If it errors, reuse the name.

    Code:
    Public Function AddSelectionSet1(SetName As String) As AcadSelectionSet
    ' This routine does the error trapping neccessary for creating selection sets.
        On Error Resume Next
        Set AddSelectionSet = ThisDrawing.SelectionSets.Add(SetName)
        If Err.Number <> 0 Then
            Set AddSelectionSet = ThisDrawing.SelectionSets.Item(SetName)
        End If
    End Function
    Once you have the ss, use ss.Clear to start fresh.
    nice, better than what i used to clean before create

    Public Sub limpiadibu(x As Variant)
    Dim TestForSelSet As AcadSelectionSets
    Dim Cntr As Long
    Set TestForSelSet = AutoCAD.Application.ActiveDocument.SelectionSets
    If AutoCAD.Application.ActiveDocument.SelectionSets.Count > 0 Then
    For Cntr = 0 To AutoCAD.Application.ActiveDocument.SelectionSets.Count - 1
    If TestForSelSet(Cntr).Name = "SS2" Then
    AutoCAD.Application.ActiveDocument.SelectionSets.Item("SS2").Delete
    End If
    Next Cntr
    End If
    End Sub

  7. #7
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,397
    Login to Give a bone
    0

    Default Re: Erasing a selection set name

    Even if you were going that route, remember that ss's are in a collection and you can ForEach those.
    Code:
    Function AddSelectionSet (name As String) As AcadSelectionSet
       Dim ss As AcadSelectionSet
       For Each ss In ThisDrawing.AcadSelectionSets
          If ss.Name = name Then
             ss.Clear
             Set AddSelectionSet = ss
          Else
             Set AddSelectionSet = ThisDrawing.SelectionSets.Add name
          End If
    End Function
    C:> ED WORKING....

  8. #8
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,397
    Login to Give a bone
    0

    Default Re: Erasing a selection set name

    Forget that, that's going to try and add an ss for each ss in the collection. It will error the next loop. But I just wanted to show you how to iterate with For Each.
    C:> ED WORKING....

  9. #9
    AUGI Addict sinc's Avatar
    Join Date
    2004-02
    Location
    Colorado
    Posts
    1,986
    Login to Give a bone
    0

    Default Re: Erasing a selection set name

    Quote Originally Posted by eljobe
    You don't have to worry about getting rid of ss's, they're only temporary in the dwg. When you close the dwg, the ss collection is cleared.
    What about this statement from the documentation?
    Attempting to manage a large number of selection sets simultaneously is not recommended. An AutoLISP application cannot have more than 128 selection sets open at once. (The limit may be lower on your system.) When the limit is reached, AutoCAD refuses to create more selection sets. Keep a minimum number of sets open at a time, and set unneeded selection sets to nil as soon as possible. If the maximum number of selection sets is reached, you must call the gc function to free unused memory before another ssget will work.

  10. #10
    All AUGI, all the time
    Join Date
    2003-10
    Posts
    706
    Login to Give a bone
    0

    Default Re: Erasing a selection set name

    What about this statement from the documentation?
    I guess that is talking about in the current open drawing. As soon as another is opened the selection set count is reset.


    From the help file:
    "The Delete method deletes a selection set and all items in the selection set. Neither the selection set, nor the items previously in the selection set will exist after a call to the Delete method."
    Also, my documentation about deleting the entities in the selection set came from an old help file. I guess they changed that feature after Acad 14?

Page 1 of 2 12 LastLast

Similar Threads

  1. Erasing everything outside a boundary
    By Stephen.Walz in forum AutoLISP
    Replies: 12
    Last Post: 2019-05-13, 01:28 AM
  2. Erasing Design Options
    By Bryan Thatcher in forum Revit Architecture - General
    Replies: 7
    Last Post: 2010-04-26, 02:33 PM
  3. Erasing Alignment Labels
    By jpaulsen in forum AutoCAD Civil 3D - General
    Replies: 4
    Last Post: 2007-05-11, 03:03 PM
  4. erasing titles
    By tect75 in forum Revit Architecture - General
    Replies: 3
    Last Post: 2006-03-20, 03:28 PM
  5. Phase Erasing?
    By gregcashen in forum Revit Architecture - General
    Replies: 5
    Last Post: 2003-09-18, 07:21 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •