Problem with ActiveSelectionSet

Discussion in 'AutoCAD' started by dzentrich, Aug 4, 2004.

  1. dzentrich

    dzentrich Guest

    I am trying to use ThisDrawing.ActiveSelectionSet to get the objects that the user has selected when the AcadDocument_SelectionChanged event fires.

    The problem I am having is that when the SelectionChanged event fires for the first time, the ActiveSelectionSet is empty. It appears that the ActiveSelectionSet isn't updated until after the SelectionChanged event completes.

    Does anyone know of any work arounds or different methods for determining what objects the user has selected?

    -Thanks
    Dave Z.
     
    dzentrich, Aug 4, 2004
    #1
  2. dzentrich

    Kevin Terry Guest

    I'm not sure this is what you're looking for, but I use this code to run on
    a gripped set or request a user to select items, depending on if anything is
    already selected. It's not the cleanest routine, but works pretty well.

    'in the calling procedure:
    Dim acSelection As AcadSelectionSet
    Set acSelection = Gripped_Set()

    'function:
    Public Function Gripped_Set() As AcadSelectionSet

    Dim acTempSet As AcadSelectionSet
    Dim iE As Long

    ThisDrawing.StartUndoMark

    On Error GoTo GrippedSetErr

    Set acTempSet = ThisDrawing.PickfirstSelectionSet

    If acTempSet.Count <> 0 Then
    GoTo Exit_Sub
    End If

    GrippedSetErr:

    Err.Clear

    On Error Resume Next

    Set acTempSet = ThisDrawing.SelectionSets.Add("UserSet" & iE)

    Do While Err.Number <> 0
    Set acTempSet = ThisDrawing.SelectionSets.Add("UserSet" & iE)
    iE = iE + 1
    Loop

    On Error GoTo 0

    acTempSet.SelectOnScreen

    Exit_Sub:

    Set Gripped_Set = acTempSet

    ThisDrawing.EndUndoMark

    Set acTempSet = Nothing

    End Function


    hth,
    Kevin


    the user has selected when the AcadDocument_SelectionChanged event fires.
    the first time, the ActiveSelectionSet is empty. It appears that the
    ActiveSelectionSet isn't updated until after the SelectionChanged event
    completes.
    what objects the user has selected?
     
    Kevin Terry, Aug 5, 2004
    #2
  3. dzentrich

    dzentrich Guest

    Kevin, that is very helpful - thanks! I hadn't thought of using the PickfirstSelectionSet property (actually I haven't used it before, and thought that was what I was getting with the ActiveSelectionSet).

    Anyway, I substituted ThisDrawing.PickfirstSelectionSet for ThisDrawing.ActiveSelectionSet in my function and it works the way I need it to!

    -Thanks
    Dave Z.
     
    dzentrich, Aug 6, 2004
    #3
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.