This Lisp reactor doesn't seem to work correctly
It used to update the properties bar immediately and now doesn't. It used to return to previous layer and now doesn't.
(vl-load-com);****************************************(vlr-command-reactor nil '((:vlr-commandWillStart . startCommand)))(vlr-command-reactor nil '((:vlr-commandEnded . endCommand)))(vlr-command-reactor nil '((:vlr-commandCancelled . cancelCommand)));******************************************************(defun startCommand (calling-reactor startcommandInfo / thecommandstart)(setq OldLayer (getvar "CLAYER"))(setq thecommandstart (nth 0 startcommandInfo))(cond ((= thecommandstart "TEXT") (setvar "CLAYER" "TEXT")) ((= thecommandstart "MTEXT") (setvar "CLAYER" "TEXT")) ((= thecommandstart "DTEXT") (setvar "CLAYER" "TEXT")) ((= thecommandstart "DIMLINEAR") (setvar "CLAYER" "DIM")) ((= thecommandstart "DIMALIGNED") (setvar "CLAYER" "DIM")) ((= thecommandstart "DIMLEADER") (setvar "CLAYER" "DIM")) ((= thecommandstart "DIMCONTINUE") (setvar "CLAYER" "DIM")) ((= thecommandstart "DIMANGULAR") (setvar "CLAYER" "DIM")) ((= thecommandstart "HATCH") (setvar "CLAYER" "HATCH")) ((= thecommandstart "BHATCH") (setvar "CLAYER" "HATCH")));cond(princ));defun;****************************************************(defun endCommand (calling-reactor endcommandInfo / thecommandend)(setq thecommandend (nth 0 endcommandInfo))(cond ((= thecommandend "TEXT") (setvar "CLAYER" OldLayer)) ((= thecommandend "MTEXT") (setvar "CLAYER" OldLayer)) ((= thecommandend "DTEXT") (setvar "CLAYER" OldLayer)) ((= thecommandend "HATCH") (setvar "CLAYER" OldLayer)) ((= thecommandend "BHATCH") (setvar "CLAYER" OldLayer)) ((= thecommandstart "DIMLINEAR") (setvar "CLAYER" OldLayer)) ((= thecommandstart "DIMALIGNED") (setvar "CLAYER" OldLayer)) ((= thecommandstart "DIMLEADER") (setvar "CLAYER" OldLayer)) ((= thecommandstart "DIMCONTINUE") (setvar "CLAYER" OldLayer)) ((= thecommandstart "DIMANGULAR") (setvar "CLAYER" OldLayer)));cond (princ));defun;********************************************************(defun cancelCommand (calling-reactor cancelcommandInfo / thecommandcancel)(setq thecommandcancel (nth 0 cancelcommandInfo))(cond ((= thecommandcancel "TEXT") (setvar "CLAYER" OldLayer)) ((= thecommandcancel "MTEXT") (setvar "CLAYER" OldLayer)) ((= thecommandcancel "DTEXT") (setvar "CLAYER" OldLayer)) ((= thecommandcancel "HATCH") (setvar "CLAYER" OldLayer)) ((= thecommandcancel "BHATCH") (setvar "CLAYER" OldLayer)) ((= thecommandstart "DIMLINEAR") (setvar "CLAYER" OldLayer)) ((= thecommandstart "DIMALIGNED") (setvar "CLAYER" OldLayer)) ((= thecommandstart "DIMLEADER") (setvar "CLAYER" OldLayer)) ((= thecommandstart "DIMCONTINUE") (setvar "CLAYER" OldLayer)) ((= thecommandstart "DIMANGULAR") (setvar "CLAYER" OldLayer)));cond(princ));defun;*********************************************************(princ)
Not that big a deal but was wondering what changed recently.?
Comments
-
Hello, Jerry,in older Bricscad builds, the Properties panel and some other GUI elements were immediately updated with every change - like current layer.But that design caused a significant performance slowdown, if you have Lisp and/or ADS/SDS/ARX/DRX code running, which often changes such properties ... in result, the execution was measurable slower, because the GUI update costs a lot of time.So Bricscad uses a more intelligent logic now, and the GUI objects are updated with delay ... we carefully compared this with AutoCAD : here, such GUI updates are also delayed.Normally, when your Lisp code is finished, the Properties panel and other GUI elements like statusbar fields should be updated then.However, I will use your code here and will test the behaviour ... both in Acad and Bricscad.I will keep you updated here ...Many greetingsTorsten
0 -
I just forgot to mention ...The Lisp reactors did not change at all ... so your Lisp reactor callback routines should be called, still - and also (setvar "clayer" oldlayer) will work and set the current layer.It is only the Property panel (and other GUI elements) which do not immediately reflect that change, if the (Lisp) code still runs ...Many greetingsTorsten
0 -
The code works, however I'm used to looking at the property bar and seeing the layer that I'm currently working in. If I look at the status bar, it immediately updates to the layer, maybe the property bar should be tied as tightly.? Maybe the properties bar should just read the status bar's properties?Just an annoyance. Thanks for your response.
0 -
Hello, Jerry,can you send me your program or a kind of subset which shows that effects ?As I would like to reproduce ...Normally, it is intended, that the Properties panel is updated when the process is idle - i.e. when waiting for an user input.But if a (Lisp) program runs without user interaction, then the Properties panel update is delayed until next idle status, when (Lisp) code has finished ...At least, this is the intention behind.But if your sample code shows, that the Properties panel is not updated even when waiting for user input, then this needs to be changed, for sure.My email :torsten.moses@bricsys.comMany greetingsTorsten
0 -
The code first above posted was cut from on-doc-load or such named autoload lisp file and works fine except that the properties bar does not reflect the layer change although the layer has been changed, witness the status bar and the ensuing entity's layer. Since the endcommand reactor reverts back to the initial layer.This code was probably copied from AfraLisp or some such site.
0 -
Hello Jerry,As Torsten said, Bricscad updates the GUI only when it is in idle state, you could say when it is "in between commands". I tried your code, and when I comment out the endCommand and cancelCommand reactors, the properties bar shows e.g. the layer "TEXT", after the TEXT command was finished. So, indeed, during the TEXT command, the properties bar shows the wrong layer. We will investigate how to fix that, without losing the performance improvement we gained by delaying the GUI update. By the way, thanks for the suggestion about the status bar, but our plans are more or less in the opposite direction: now the status bar updates continuously. We plan to implement the same delay there, i.e. the status bar will get its info from the properties (tool)bar.
0 -
Would it be possible to code a GUI update into the lisp code? That way the user could choose performance or not at their liking. Might require using some com objects or such.
0 -
We've fixed the problem. Whenever Bricscad starts waiting for user input, the GUI elements are first updated, so in your example the correct layer will be shown at any time. This will be available in an upcoming release.
0