Command Name to Load and Run an MDI macro?

Discussion in 'AutoCAD' started by James Allen, Nov 22, 2004.

  1. James Allen

    James Allen Guest

    I have an mdi macro that works fine unless I call it from the command line
    using its lisp wrapper c: name. Then it hangs as soon as the active
    document changes, until I manually switch back to the 'calling document'
    from which point it continues to run in the wrong document.

    Is it possible to provide a command name to load (if not already loaded) and
    run a vba macro that changes active document, and have it continue to run as
    it should? Or am I just out of luck? I guess in the meantime I will just
    have to fully load it at startup and provide a menu item with an
    accelerator.
     
    James Allen, Nov 22, 2004
    #1
  2. i think you're problem could be the way your running the vba from lisp
    this may or may not be the answer but try using (vl-vbarun ....) in the lisp
    routine instead of (command "vbarun" .......)

    hope this helps

    cheers

    mark
     
    Mark Dubbelaar, Nov 23, 2004
    #2
  3. The C:TEST command example below should terminate
    before execution of the VBA macro that it starts.

    Replace "yourmacroname" with the name of the macro
    you want to start.

    (defun C:TEST ()
    (sendmacro "YourMacroName")
    (princ "\nExiting C:TEST")
    (princ)
    )

    (defun sendmacro (macroname)
    (vla-sendcommand
    (vla-get-activedocument
    (vlax-get-acad-object)
    )
    (strcat "-VBARUN " macroname " ")
    )
    (princ)
    )

    (if (not vlax-get-acad-object)
    (defun vlax-get-acad-object ()
    (vl-load-com)
    (vlax-get-acad-object)
    )
    )
     
    Tony Tanzillo, Nov 23, 2004
    #3
  4. James Allen

    James Allen Guest

    Thank you Tony, vla-sendcommand did the trick. Yet another example of where
    sendcommand does what others won't. Makes me wonder again, what is so
    different about vla-sendcommand than command or vl-cmdf (and in this case
    vl-vbarun)? Apparently there is some timing/synchronization difference?

    Many thanks,

    James
     
    James Allen, Nov 23, 2004
    #4
  5. James Allen

    James Allen Guest

    Hi Mark, I guess I should have posted how I was loading it, but just so you
    know, vla-runmacro is what I had been using (because I had already had other
    problems with the command version in the past) and got the results I
    described. Tony got it though.

    Thank you,

    James
     
    James Allen, Nov 23, 2004
    #5
  6. James Allen

    James Allen Guest

    Hi again Anne,

    Here is another example. I replied to both Mark and Tony in this thread.
    Both of my replies show at home (nttp) but not at work (also nttp).

    Thank you,

    James
     
    James Allen, Nov 24, 2004
    #6
  7. James Allen

    Anne Brown Guest

    Hi James -

    I will pass this along but think it is probably a work site
    related problem. I see your replies to both Tony and Mark in both
    nntp and http. I know you have been a discussion group user for a
    long time. Is it possible you have your Outlook Express at work
    set to not show your own messages? Check how the defaults are
    set.
     
    Anne Brown, Nov 24, 2004
    #7
  8. James Allen

    James Allen Guest

    I will pass this along but think it is probably a work site related
    problem.
    I was originally inclined to think the same, but it seems so random.
    So do I, but only at home. As I've mentioned before, it happens both
    places.
    If that were the case, wouldn't I never see my own messages? It happens to
    my own posts (but only occasionally), and other people's (also only
    occasionally AFAIK). I have it set to show all messages in both places. I
    remember others mentioning the same (I think) problem several months ago as
    well, which leads me to think it is not just me. But of course I could be
    wrong.

    Thank you,

    James
     
    James Allen, Nov 24, 2004
    #8
  9. What vla-sendcommand does in essence, is stuffs the keyboard
    buffer with characters, which AutoCAD fetches when it is ready
    to begin polling for input again (which is not until it returns to a
    quiescent state, when the calling LISP function terminates).

    In other words, vla-sendcommand is basically doing nothing but
    typing keystrokes for you.

    Nothing like a modern, sophisticated API, eh?
     
    Tony Tanzillo, Nov 24, 2004
    #9
  10. James Allen

    James Allen Guest

    A menu macro button for ActiveX... ;) That makes sense with what I've
    seen.

    Thanks again,

    James
     
    James Allen, Nov 24, 2004
    #10
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.