ACAD Command Stack question

Discussion in 'AutoCAD' started by Maksim Sestic, Jan 5, 2004.

  1. Dear All,

    Here's a nifty problem that keeps me away from using VBA SendCommand and
    it's API surrogates for a while. All other technical problems aside (like
    it's asynchronous properties), the major drawback is the one that's obvious
    to the user:

    1) There is a menu option that fires certain VBA macro - let's call that Sub
    module "Macro1"
    2) When Macro1 subroutine gets started, it performs some calculations and
    executes SendCommand ".Zoom"
    3) User wants to repeat the last command picked from the menu (Module1)
    using his/her right mouse button or whatever he/she's used to...
    4) And, oh, the command stack says "Yeah, forget the Macro1, the last issued
    command was ZOOM"

    Is there a way to fill the command stack with certain command, without
    actually firing that command? What's the location of that stack (I guess
    it's saved in memory only, no registry entries affected) and are there any
    means to change it? Is there a possible workaround?

    Regards and Happy New Year to all,
    Maksim Sestic
     
    Maksim Sestic, Jan 5, 2004
    #1
  2. Hi Malcolm,

    An approach to this problem is to define AutoCAD commands with lisp to run
    your macros.
    With things like zooming you should use the APIs rather than SendCommand.
    This combination will allow you to repeat.

    Below is an extract of the CADApps LandToolbox.MNL file which shows a way of
    doing this.

    "CA_DuplicatePoints" is the defined command which can be run from the
    command line, pop menu or a toolbar. As it is a command it will be placed
    in the used commands register and can be repeated by pressing <Enter>

    Laurie Comerford
    CADApps
    www.cadapps.com.au


    ;//
    ;// AutoCAD menu file - C:\Program Files\Land Desktop
    3\Support\LandToolbox.mnl
    ;//
    ;// 7 Jun 2003 Modified to hide data other than the menu command itself

    (setq sLandToolboxPath
    (strcat
    (vl-registry-read
    "HKEY_LOCAL_MACHINE\\Software\\CADApps\\LandToolbox" "VBA Program Path")
    "\\"
    )
    )

    (setq sLandToolboxHelpPath
    (vl-registry-read
    "HKEY_LOCAL_MACHINE\\Software\\CADApps\\LandToolbox" "Help Path")
    )

    (defun CADApps_BlankCommandLine (spString)
    (setq n (strlen spString))
    (repeat n(prompt(chr 8)))
    (repeat n(prompt(chr 32)))
    (princ)
    ) ; CADApps_BlankCommandLine

    (defun C:CA_LandToolBoxHelp ()
    (Command "Browser" (strcat sLandToolboxHelpPath "\\LT_HelpIndex.htm"))
    (CADApps_BlankCommandLine (strcat sLandToolboxHelpPath
    "\\LT_HelpIndex.htm"))
    ) ; end Defun CA_LandToolBoxHelp


    (defun C:CA_DuplicatePoints ()
    (setq sLandToolboxFunction (strcat sLandToolboxPath
    "CADApps_DuplicatePointsL3.dvb!DuplicatePoints"))
    (vl-vbarun sLandToolboxFunction)
    (CADApps_BlankCommandLine sLandToolboxFunction)

    ) ; end Defun CA_DuplicatePoints


    <snip>
     
    Laurie Comerford, Jan 5, 2004
    #2
  3. Laurie,

    Thanks for the tip. The thing is that I'm primarily using VBA, having to
    execute VBA SendCommand only there where AutoCAD doesn't have it's functions
    exposed via object model. Here's the operations flowchart:

    (1) Run VBA Macro named "MACRO1"
    (2) Run SendCommand "-boundary ... ... ..." via MACRO1
    (3) Continue execution of MACRO1...
    (4) End MACRO1

    If user repeats the last command issued, it will be rather "-boundary" than
    "MACRO1".
    The question is - how do I trick the ACAD command stack?

    Thanks,
    Maksim Sestic
     
    Maksim Sestic, Jan 6, 2004
    #3
  4. As Laurie correctly stated, your command stack should be:
    (1) Run VBA Macro named "MACRO1" *VIA AUTOLISP WRAPPER*
    (2) Run SendCommand "-boundary ... ... ..." via MACRO1
    (3) Continue execution of MACRO1...
    (4) End MACRO1
    (5) User now has access to Macro1 as the last command
     
    Mike Tuersley, Jan 6, 2004
    #4
  5. AutoCAD is being fed the -BOUNDARY command
    after your VBA macro is run, so that means
    its the last command entered.

    I'm afraid there's no way to solve that
    problem other than by using AcadX.arx
     
    Tony Tanzillo, Jan 6, 2004
    #5
  6. Ed, what I'm really stuck is -Boundary command, the Zoom example was just to
    make things more clear.

    Thanks,
    Maksim Sestic

    Don't use SendCommand, use one of the Zoom methods of the AcadApplication
    object.
     
    Maksim Sestic, Feb 12, 2004
    #6
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.