SelectionChanged event and lisp code

SelectionChanged event and lisp code

mdhutchinson
Advisor Advisor
405 Views
4 Replies
Message 1 of 5

SelectionChanged event and lisp code

mdhutchinson
Advisor
Advisor
okay... I am using SelectionChanged event in ThisDrawing.
within this event procedure I am running some lisp to deselect and turn off grips as follows:
[code]
ThisDrawing.SendCommand _
"(load " & Chr(34) & "VlaSStoLispSS" & Chr(34) & ")" & vbCr
'| | | | |--- carraige return
'| | | |--- closing lisp parens
'| | |--- embedded double quote
'| |---- lisp file to load (from IpcLisp folder - in AutoCAD Search Path)
'|-------------- embedded double quote mark

SendCommand "(VlaSS>LispSS) "
SendCommand "(sssetfirst) "
SendCommand "(sssetfirst nil LispSS) "
[/code]

The basic idea was taken from this post:
http://discussion.autodesk.com/thread.jspa?messageID=4056447

The trouble I am having is that the lisp code it tripping the event again so that it continues in a continual loop.

I tried putting the body of the code in a condition... but as soon as my app resets the boolean (in a completely different module) the event starts looping continuously again.

anyone have any ideas how I can stop the recursiveness but let it run the next time the user does a selection in the drawing?
0 Likes
406 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
See help "Guidelines for Writing Event Handlers"

You can't reliably/predictably use "SendCommand" in an event handler.

HTH,

Gary
0 Likes
Message 3 of 5

mdhutchinson
Advisor
Advisor
thanks... I'll take a look at this help...

If I move the sendcommand and lisp calls to a bas module but call it from the event procedure wouldn't this work?
0 Likes
Message 4 of 5

Anonymous
Not applicable
>>If I move the sendcommand and lisp calls to a bas module but call it from
the event procedure wouldn't this work?

I don't think so. I think you would be taking a slight detour but would
still actually be in the event handler. I've had these same kinds of
problems trying to change things in various event handlers. Sometimes I've
been able to devise a workaround but it usually isn't easy and turns into a
real hack.

Another thing help mentions is to not do anything inside an event handler
that will cause the same event to fire again. Looks like you have a double
whammy going on there. The sendcommand and the double (possibly endless)
trigger.

Gary
0 Likes
Message 5 of 5

mdhutchinson
Advisor
Advisor
Yes... that's what I suspected and confirmed when I read the help you suggested...

one thought though... I have a modeless dialog box with a AcFocusCtrl1 running... the app is done in such a way as to allow selection of certain blocks directly from the drawing or access them by clicking a item in a list box. In the case of user selection from the dwg the SelectionChanged event procedure causes the matching entry in the list box to be selected.
When the user selects the objects from the drawing and then moves to the user form clicking an item in the list box the items click event checks to see if there is a pickfirstset that exists... if it does then I do SendCommand "(sssetfirst) ", but the SelectionChanged event doesn't fire (which is good).

The interesting thing is my application creates multiple selection sets in multiple drawings but the Selection Changed event doesn't fire at all (also what I want).

What I am after with all this is to allow the user to select one or many objects in the drawing but leave only the blocks which my app is interested in selected and grips turned on. If I could simply find a way to exclude objects of NON interest from the SS it would give my app the effortlessness that I'd like to achieve.

[pause to try moving the lisp outside the Selection Changed event]
Well you were right... this didnt' work either.
I guess I'll note 'doesn't work' and comment this out unitl I can find another solution.

Message was edited by: hutch
0 Likes