Problem with SelectionSet

Problem with SelectionSet

Anonymous
Not applicable
149 Views
2 Replies
Message 1 of 3

Problem with SelectionSet

Anonymous
Not applicable
I've got a problem with the SelectionSet.SelectOnScreen method that is
keeping me busy for a long time now.
The method stops when for example a button in the Zoom-toolbar is activated.
I thought I could solve this with error-handling and
the API-call AsyncKeyState (Enter-, Esc-key etc.). BUT: The method just
stops without giving an error!

Does anyone know a way to keep the Select method running and use the
transparant zoom functions too.
(Maybe a nice question for Frank, the SelectionSet expert.....)

Greetings,
Henk
0 Likes
150 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
I don't know about being an expert but I do know the problem you describe
only happens when using a toolbar in the middle of a macro. An ugly little
workaround is to use 'Z at the keyboard instead.

--
Attitudes are contagious. Is yours worth catching?
http://www.acadx.com

"Henk Loonstra" wrote in message
news:0287DC41AFBA8D94F4043AA28D4F3A7B@in.WebX.SaUCah8kaAW...
> I've got a problem with the SelectionSet.SelectOnScreen method that is
> keeping me busy for a long time now.
> The method stops when for example a button in the Zoom-toolbar is
activated.
> I thought I could solve this with error-handling and
> the API-call AsyncKeyState (Enter-, Esc-key etc.). BUT: The method just
> stops without giving an error!
>
> Does anyone know a way to keep the Select method running and use the
> transparant zoom functions too.
> (Maybe a nice question for Frank, the SelectionSet expert.....)
>
> Greetings,
> Henk
>
0 Likes
Message 3 of 3

Anonymous
Not applicable
I did hope you maybe had the answer, I think a lot of VBA-programmers
struggle with this limitation of the method.
My latest attempt is the following code.
It is not exact the way a user works with AutoCAD but it approaches normal
behaviour:

When the user has selected some entities he has to push the right
mousebutton before a Zoom-button is pressed, otherwise the selected items
don't become part of the selectionset. The only way to quit the
select-action is to push on the Enter-button (keyboard) to succeed or Escape
to cancel the procedure.

Maybe something to develop or improve,
Henk

Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long)
As Integer
Private Const VK_ESCAPE = &H1B
Private Const VK_ENTER = &HD

Public Sub ExtendedSelection()
Dim objSS As AcadSelectionSet
Dim intCode(0) As Integer, varCodeValue(0)

On Error Resume Next
Set objSS = ThisDrawing.SelectionSets("Temporary")
If objSS Is Nothing Then
Set objSS = ThisDrawing.SelectionSets.Add("Temporary")
Err.Clear
End If

intCode(0) = 0: varCodeValue(0) = "LINE"

Selection:
If Not objSS.Count = 0 Then objSS.Highlight True
On Error GoTo KeyPress
objSS.SelectOnScreen intCode, varCodeValue

KeyPress:
If (GetAsyncKeyState(VK_ESCAPE) And &H8000&) Then
objSS.Highlight False
objSS.Delete
Set objSS = Nothing
Exit Sub
ElseIf (GetAsyncKeyState(VK_ENTER) And &H8000&) Then
ThisDrawing.Utility.prompt objSS.Count & " entities selected." & vbLf
objSS.Highlight False
objSS.Delete
Set objSS = Nothing
Else
GoTo Selection
End If

End Sub
0 Likes