Tilemode reactor problem

I've been trying to get this reactor thingy to work in Bricscad V10.

It's supposed to set the "LTSCALE" variable to 10 in paperspace and to a stored value in modelspace.

It seems to be loaded, but nothing happens.

It seems to work okay in Autocad 2000.

(This is my first attempt at a reactor or anything else in Vlisp)

(vl-load-com)
(setq CommandEndedReactor_Space nil Reactor_Function_Space nil )

(defun Reactor_Function_Space ( Arg1 Arg2 / )
(if (= (car Arg2 ) "-LAYOUT" )
(cond
((= (getvar "TILEMODE" ) 1 )
(setq @dwg (if @dwg @dwg 100))
(setvar "LTSCALE" @dwg)
(setvar "PSLTSCALE" 1)
(setvar "REGENMODE" 0)
(princ)
)
((= (getvar "TILEMODE" ) 0 )
(setvar "LTSCALE" 10)
(setvar "PSLTSCALE" 1)
(setvar "REGENMODE" 1)
)
)
)
)
(setq CommandEndedReactor_Space
(vlr-command-reactor nil '((:vlr-commandEnded . Reactor_Function_Space )))
)
(defun c:terminate_tlm()
(vlr-remove CommandEndedReactor_Space )
(setq CommandEndedReactor_Space nil Reactor_Function_Space nil )
)

Comments

  • Dear Yaacov, you are using a command reactor - and inside the callback, you check for -LAYOUT (as command name);
    so far so good - but this can only work, if command -LAYOUT has been enterd - but there is no such command :-)
    But even if -LAYOUT would exist, this reactor would not fire i.e. if the layout is changed by mouse, or by other code.

    A better approach is to place a SYSVARCHANGED reactor :
    (setq reactor (vlr-sysvar-reactor nil '((:vlr-sysVarChanged . callback))))

    Thus, you can monitor layout and tilemode switches ...

    But now for the problems ... there are bugs currently, in both Acad and Bricscad, regarding system variables fired as reactor :

    - Acad does correctly fire TILEMODE changes - but not sends the reactor for CTAB;
      when switching from model to layout1, and back, then TILEMODE is fired;
      when switching from Layout1 to Layout2 (and back), no reactor for CTAB is sent;
      => in fact, I did not found a safe + stable case to recognise Layout1 -> Layout2 switch, based on reactors ... in Acad

    - Bcad does correctly send CTAB always - but not always for TILEMODE :-(
      but at least, when checking for CTAB in reactor callback, you can additionally check for TILEMODE by /getvar "TILEMODE"),
      so you have a safe + stable way to recognise all layout switches

    I will report the TILEMODE system variable problem to our internal task list.

    I use such simple code to examine the behaviour :

    (vl-load-com)   ;; never forget this ! in Bcad it is a NO-Operation, but nessecary for Acad !
    (defun cb (arg1 arg2) (print "--- cb ---")(print arg1)(print arg2)(print "*********")(princ))
    (setq xxx (vlr-sysvar-reactor nil '((:vlr-sysVarChanged . cb))))

    I hope this code sample helps ?
    Many greeitngs, Torsten

  • Great! I'll try it.

    Undoubtedly I'll have more dumb questions as I mess with reactors.

    I'm always impressed by the seriousness of the technical support and design people in bcad.
    There's a lot of fascinating stuff "under the hood", and I'm always interested in hearing about it.

  • Of course, you are always welcome :-) With *any* kind of question ...

This discussion has been closed.