Error on Selection set 'IAcadSelectionSet' failed

Discussion in 'AutoCAD' started by Yves, Feb 18, 2004.

  1. Yves

    Yves Guest

    I get this message after using it succesfully for a while, and the only way
    I get to correct this (for now) is close Autocad and start again.
    The error is :

    Run time error -2147467259 (800004005)
    Method 'Count' of object 'IAcadSelectionSet' failed

    The error occurs at the line : If sset.count > 0 Then

    Can someone point where I might have made an error

    Here is the code : (it deletes all the objects on a specific layer)

    Sub DelLay(NomLayer As String)
    Dim sset As AcadSelectionSet, ent As AcadEntity, curLay As AcadLayer
    Dim ft(0) As Integer, fd As Variant
    Dim cadObject As AcadEntity, pt
    Set sset = Nothing
    Set sset = ThisDrawing.PickfirstSelectionSet
    sset.Clear
    ft(0) = 8 ' layer name
    sset.Clear
    fd = Array(NomLayer)
    sset.Select acSelectionSetAll, , , ft, fd
    If sset.count > 0 Then
    ThisDrawing.Utility.Prompt ("Efface le layer : " & NomLayer & vbCr &
    vbLf)
    For Each ent In sset
    If TypeName(ent) <> "IAcadPViewPort" Then
    ent.Delete
    End If
    Next
    End If
    Set sset = Nothing
    End Sub
     
    Yves, Feb 18, 2004
    #1
  2. Yves

    developer Guest

    First, initialize a new selection set using Set sset = ThisDrawing.SelectionSets.Add("YourSelSetNameHere"). Then, when you are finished operating on it, use the sset.Delete method. Forget about using Set sset = Nothing. If you forget to use the Delete method, AutoCAD will eventually throw the error 'named selection set already exists'.
     
    developer, Feb 18, 2004
    #2
  3. Yves

    Yves Guest

    Thanks,

    I tried it, so far, it works.. :)


    ThisDrawing.SelectionSets.Add("YourSelSetNameHere"). Then, when you are
    finished operating on it, use the sset.Delete method. Forget about using
    Set sset = Nothing. If you forget to use the Delete method, AutoCAD will
    eventually throw the error 'named selection set already exists'.
     
    Yves, Feb 18, 2004
    #3
  4. Tony Tanzillo, Feb 18, 2004
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.