Dummy Command Problem

Discussion in 'AutoCAD' started by Blair MacKenzie, May 13, 2004.

  1. Have tried to use dummy command workaround to allow my F6 button to toggle
    mbutton pan on and off but to no avail.
    Have tried so many different options with code over last 4 months that I'm
    completely lost.
    Thsi works sometimes but not all the time. Still get "document mismatch"
    error.

    Have this in accelerators section of menu file.
    ["F6"]'mbswap

    Lisp file is as follows.

    Any help would be much appreciated.

    (defun mbswap ()
    (vl-load-com)

    ;;; Workaround for (vlax-add-cmd) bug.
    ;;; by Stephan Koster

    ;; Comments by JRF: This code should be
    ;;; run before adding any other commands with vlr-add-cmd.
    ;;; Otherwise, when using added commands in multiple documents
    ;;; (MDI mode), sometimes the commands fail with a "Visual LISP
    ;;; command document mismatch" error. Apparently vlax-add-cmd
    ;;; must be called in a document in order to activate commands
    ;;; in that document.
    (defun DummyCommand () NIL)
    (vlax-add-cmd "DummyCommand" 'DummyCommand)
    (defun AddCommandsHelper (a b)
    (vlax-add-cmd "DummyCommand" 'DummyCommand)
    )
    ;; Install dummy command reactor only if it's not
    ;; defined already
    (or DummyCommandReactor
    (setq DummyCommandReactor
    (vlr-docmanager-reactor
    NIL
    '(:)vlr-documentBecameCurrent . AddCommandsHelper))
    )
    )
    )
    ;
    ;(defun mbswap ()
    (setvar "mbuttonpan" (abs (1- (getvar "mbuttonpan"))))
    (SETVAR "CMDECHO" 1)
    (princ)
    )
    (vlax-add-cmd "mbswap" 'mbswap "mbswap" 1)
     
    Blair MacKenzie, May 13, 2004
    #1
  2. Blair MacKenzie

    OLD-CADaver Guest

    Haven't a clue about your reactors here, but the following works for us. Just add (mbp) to F6.


    ;;;;start code
    (defun mbp ()
    (if
    (= (getvar "mbuttonpan") 0)
    (setvar "mbuttonpan" 1)
    (setvar "mbuttonpan" 0)
    )
    (TERPRI)
    )
    ;;;;;end code
     
    OLD-CADaver, May 13, 2004
    #2
  3. Doesn't allow use of toggle during a lisp command hence the use of vlax-add.
    Have had some previous replies to use Dummy Command but there still must be
    something wrong with my lisp.

    Blair.
     
    Blair MacKenzie, May 14, 2004
    #3
  4. Blair MacKenzie

    Randall Culp Guest

    try
    ["F6"](mbswap)
     
    Randall Culp, May 14, 2004
    #4
  5. If in mid command (lisp command) still get "Can't reenter LISP"

    Blair.

     
    Blair MacKenzie, May 14, 2004
    #5
  6. Blair MacKenzie

    Jürg Menzi Guest

    OLD-CADaver

    Why complicated if you can get it the easy way?
    (setvar "MBUTTONPAN" (boole 6 (getvar "MBUTTONPAN") 1))

    Cheers
     
    Jürg Menzi, May 14, 2004
    #6
  7. If in mid command (lisp command) still get "Can't reenter LISP"

    '_setvar;MBUTTONPAN;$M=$(if,$(eq,$(getvar,MBUTTONPAN),0),1,0)

    --
    ________________________________________________

    Marc'Antonio Alessi
    http://xoomer.virgilio.it/alessi
    (strcat "NOT a " (substr (ver) 8 4) " guru.")
    ________________________________________________
     
    Marc'Antonio Alessi, May 14, 2004
    #7
  8. Blair MacKenzie

    OLD-CADaver Guest

    You won't believe the number of routines I have prior to finding boole. I could go back and edit, but I'm basically lazy.
     
    OLD-CADaver, May 14, 2004
    #8
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.