+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Junior Member
    Using
    AutoCAD 2007
    Join Date
    Feb 2008
    Posts
    11

    Question Recognizing existence of a selectionset

    Registered forum members do not see this ad.

    How can I detect if a selectionset with a special name exist.
    I want to run the command:

    Dim sset As AcadSelectionSet
    Set sset = ThisDrawing.SelectionSets.Add("SS1")

    but maybe,for some reason the selectionset with name "SS1" already exist in the drawing, therefore an error occurs.
    any help is appreciated

  2. #2
    Super Member SEANT's Avatar
    Using
    AutoCAD 2012
    Join Date
    Aug 2005
    Location
    Rhode Island
    Posts
    1,968

    Default

    One way would be:

    Dim sset As AcadSelectionSet
    On Error Resume Next
    ThisDrawing.SelectionSets.Item("SS1").Delete
    On Error GoTo 0
    Set sset = ThisDrawing.SelectionSets.Add("SS1")

  3. #3
    Junior Member
    Using
    AutoCAD 2007
    Join Date
    Feb 2008
    Posts
    11

    Default

    Thanks for your concern
    I used this and it worked:

    If ThisDrawing.SelectionSets.Count = 0 Then
    Set sset = ThisDrawing.SelectionSets.Add("SS1")
    Else
    On Error Resume Next
    ThisDrawing.SelectionSets.Item("SS1").Delete
    On Error GoTo 0
    Set sset = ThisDrawing.SelectionSets.Add("SS1")
    End If

    thats just using what u said.Because usually the only selectionset which may exist in the drawing is SS1, I used count method.

  4. #4
    Senior Member
    Using
    AutoCAD 2008
    Join Date
    Nov 2005
    Location
    Bulgaria, Sofia
    Posts
    228

    Default

    I find it a good approach using:
    Code:
        Dim SS As AcadSelectionSet
        For Each SS In ThisDrawing.SelectionSets
            If SS.Name = "SS1" Then
                ThisDrawing.SelectionSets("SS1").Delete
                Exit For
            End If
        Next
        ThisDrawing.SelectionSets.Add ("SS1")

  5. #5
    Junior Member
    Using
    AutoCAD 2007
    Join Date
    Feb 2008
    Posts
    11

    Default

    Registered forum members do not see this ad.

    Thanks ,another nice solution

Similar Threads

  1. VBA, blocks and selectionset
    By John the frog in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 3rd Feb 2008, 10:15 am
  2. VBA : find the lowest point in a selectionset
    By John the frog in forum AutoLISP, Visual LISP & DCL
    Replies: 2
    Last Post: 2nd Feb 2008, 03:17 pm
  3. Isn't recognizing my polyline
    By Proctor in forum AutoCAD Beginners' Area
    Replies: 3
    Last Post: 15th Jan 2008, 06:51 am
  4. CAD not recognizing points
    By costaverde in forum AutoCAD Drawing Management & Output
    Replies: 6
    Last Post: 4th Dec 2007, 12:56 am
  5. Changing and Recognizing layers.
    By Kristy V in forum AutoCAD Drawing Management & Output
    Replies: 4
    Last Post: 19th Jun 2007, 04:32 pm

Bookmarks

Posting Permissions

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