VLisp hopping between active docs.

Discussion in 'AutoCAD' started by -BMC-, Oct 28, 2003.

  1. -BMC-

    -BMC- Guest

    Hit a snag while experimenting. The intent was to start from
    document1, open document2, run a procedure in doc2, return focus to
    doc1, then close doc2 without saving.

    Assuming that we have a pointer *doc1* to the first document, next:
    (setq *doc2* (vla-add (vla-get-documents (vlax-get-acad-object))))
    to get hold of the second document.

    Then a procedure which will be called from *doc2*:
    (defun-q test ()
    (<do whatever>)
    (vla-activate *doc1*))...which concludes by re-activating *doc1*.
    Now a dash of: (vl-propagate 'test)

    From *doc1* is invoked:
    (command "vbastmt" "documents.item(documents.count-1).sendcommand
    \"(test) \" ")
    ....which appears to work fine and return focus to the first document.

    But closing from the first document:
    (vla-close *doc2* :vlax-false) produces a fatal exception and Acad
    tanks.

    Aside from the obvious lack of error trapping evident in this
    thumbnail code, how are the two document objects still entwined to
    produce the fatal error??

    Right now I'm toying with more "vbastmt" to try to work around this
    little hurdle.

    Your comments are appreciated.
    B.Connoy
     
    -BMC-, Oct 28, 2003
    #1
  2. -BMC-

    -BMC- Guest

    .... note, that for sake of brevity I wrote:
    (defun-q test ()
    (<do whatever>)
    (vla-activate *doc1*))<-- when in practise this would be:

    (vla-activate (vla-item (vla-get-documents (vlax-get-acad-object)) 0)))

    BMC
     
    -BMC-, Oct 29, 2003
    #2
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.