PickFirstSelectionSet Runtime errors

Discussion in 'AutoCAD' started by a_riot, Oct 18, 2006.

  1. a_riot

    a_riot Guest

    Many of you are likely familiar with this problem and I have been
    trying to figure out a solution but haven't come up with anything.

    I have code that is generating a runtime error whenever the
    PickFirstSelectionSet is accessed after the user tries to open a file
    but cancels out of it.

    Private Sub AcadDocument_BeginRightClick(ByVal PickPoint As Variant)

    'Finds what's in the selection set we just right-clicked on
    GetPickfirstSelectionSet
    End Sub


    Public Function GetPickfirstSelectionSet()
    ' This loops through all the objects in the pickfirst selection
    set.

    Dim pfSS As AcadSelectionSet
    Dim ssobject As AcadEntity
    Dim vAtts

    Set pfSS = ThisDrawing.PickfirstSelectionSet ' RUNTIME ERROR
    HERE


    For Each ssobject In pfSS
    If TypeOf ssobject Is AcadBlockReference Then
    If Left$(ssobject.Name, 5) = "ESCD_" Then
    Set ThisDrawing.oBlock = ssobject
    vAtts = ssobject.GetAttributes
    For ix = LBound(vAtts) To UBound(vAtts) Step 1
    If vAtts(ix).TagString = "BLOCK_ID" Then
    If Not vAtts(ix).TextString = "" Then
    ThisDrawing.iBlockID =
    CInt(vAtts(ix).TextString)
    End If
    End If
    Next ix

    End If
    End If
    Next ssobject

    EnableMenus 'enable appropriate menus
    GetPickfirstSelectionSet = ThisDrawing.bBlock

    End Function



    So this all works fine until the user tries to open a file but then
    cancels out of it. Then the line ThisDrawing.PickFirstSelectionSet
    creates a Runtime Error with the error:

    Calling method AddItems of interface IAcadSelectionSet failed

    Since the PickFirstSelectionSet is read only I cannot manipulate it.
    Any idea what can cause this and how to fix/workaround it if its an
    Autocad bug?
    Many thanks,
    Paul
     
    a_riot, Oct 18, 2006
    #1
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.