Tracking currently opened drawings

Discussion in 'AutoCAD' started by sdaze, Sep 8, 2004.

  1. sdaze

    sdaze Guest

    Is there a variable that stores the drawings that are concurrently opened? I wrote a batch plotting routine that opens a predefined list of drawings, but it crashes if one of the drawings is already open. I need to be able to close specific drawings, or select a drawing if it is already open.

    TIA,
    Shaye.
     
    sdaze, Sep 8, 2004
    #1
  2. sdaze

    Joe Burke Guest

    Shaye,

    This might help.

    ;; return a list of open files with full name
    (defun ListOpenDocs (/ documents fname namelst)
    (setq documents
    (vla-get-documents
    (vlax-get-acad-object)))
    (vlax-for x documents
    (setq fname (vlax-get x 'FullName))
    (setq namelst (cons fname namelst))
    )
    )

    Joe Burke

    a batch plotting routine that opens a predefined list of drawings, but it crashes if
    one of the drawings is already open. I need to be able to close specific drawings, or
    select a drawing if it is already open.
     
    Joe Burke, Sep 9, 2004
    #2
  3. sdaze

    sdaze Guest

    Joe,

    That worked great! Is there a way to close a specific drawing, or set focus to a drawing that is concurrently opened?

    Thanks again,
    Shaye.


    Reply From: Joe Burke
    Date: Sep/09/04 - 09:00 (EDT)

    Re: Tracking currently opened drawings
    Shaye,

    This might help.

    ;; return a list of open files with full name
    (defun ListOpenDocs (/ documents fname namelst)
    (setq documents
    (vla-get-documents
    (vlax-get-acad-object)))
    (vlax-for x documents
    (setq fname (vlax-get x 'FullName))
    (setq namelst (cons fname namelst))
    )
    )

    Joe Burke

    br>> Is there a variable that stores the drawings that are concurrently opened? I wrote
    a batch plotting routine that opens a predefined list of drawings, but it crashes if
    one of the drawings is already open. I need to be able to close specific drawings, or
    select a drawing if it is already open.
     
    sdaze, Sep 9, 2004
    #3
  4. sdaze

    CJ Follmer Guest

    Why don't you open it as read-only. We have a batch plotting routine here.
    It checks whether the file is open/read-only then opens it accordingly.

    CJ

    focus to a drawing that is concurrently opened?
    Is there a variable that stores the drawings that are concurrently opened? I
    wrote
     
    CJ Follmer, Sep 9, 2004
    #4
  5. sdaze

    Joe Burke Guest

    Shaye,

    Both things you mentioned can be done, but they can be a bit tricky. For instance,
    take a look at developer help regarding the Close method. You would need to consider
    whether the file should be saved, if there are changes. Switching focus from the
    active drawing to some other open file is also messy when done programmatically.
    Frankly, I'm in over my head here. The issue is the fact the code which does the
    switch (makes some open file the active file) is initiated within the namespace of
    the currently active file. So the code can't terminate until that file is made the
    active file again. Or at least, that's how I understand it.

    How you would use the list returned by what I posted depends on your code. You'd have
    to post it, if you want to pursue this further.

    Joe Burke
    drawing that is concurrently opened?
     
    Joe Burke, Sep 10, 2004
    #5
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.