Results 1 to 7 of 7

Thread: list all open drawings?

  1. #1
    Member
    Join Date
    2008-04
    Posts
    9
    Login to Give a bone
    0

    Default list all open drawings?

    Is there a way to get a list of all the drawings that are currently open using lisp?

  2. #2
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,803
    Login to Give a bone
    0

    Default Re: list all open drawings?

    Here is one way.

    Code:
    
    
    
    (vlax-for
      x
      (vla-get-documents
        (vlax-get-acad-object)
      )
      (princ
        (strcat
          "\n"
          (vla-get-name x)
        )
      )
    )
    
    
    R.K. McSwain | CAD Panacea |

  3. #3
    Certifiable AUGI Addict
    Join Date
    2015-11
    Location
    Jo'burg SA
    Posts
    4,512
    Login to Give a bone
    0

    Default Re: list all open drawings?

    When you say "list", do you want a list of dwg filenames or com objects. Rk's given you a clue how to do either. Just be warned that you won't be able to work with those DWG's easily using Lisp.

  4. #4
    Member
    Join Date
    2012-11
    Posts
    5
    Login to Give a bone
    0

    Default Re: list all open drawings?

    Sorry for replying to such old thread but my question is really similar. Is there a way to get a list of all open drawings, but assuming I have two (or more) Autocad windows open at the same time?

  5. #5
    Login to Give a bone
    0

    Default Re: list all open drawings?

    This should work.
    Terry Cadd
    Code:
    ;-------------------------------------------------------------------------------
    ; GetDwgsList - Returns a list of open drawings
    ; Use (length (GetDwgsList)) for the number of open drawings.
    ;-------------------------------------------------------------------------------
    (defun GetDwgsList (/ AcadObj DocsObj DwgsList@)
      (setq AcadObj (vlax-get-acad-object)
            DocsObj (vlax-get-property AcadObj "Documents")
      );setq
      (vlax-for ForItem DocsObj
        (setq DwgsList@ (cons (strcat (vlax-get-property ForItem "Path") "\"
        (vlax-get-property ForItem "Name")) DwgsList@))
      );vlax-for
      (reverse DwgsList@)
    );defun GetDwgsList
    ;-------------------------------------------------------------------------------
    Last edited by BlackBox; 2019-06-25 at 01:31 PM. Reason: Please use [CODE] Tags

  6. #6
    Member
    Join Date
    2012-11
    Posts
    5
    Login to Give a bone
    0

    Default Re: list all open drawings?

    It's not exactly what I wanted.
    Lets assume I have autocad window with 2 drawings open: A.dwg and B.dwg, and another autocad window with C.dwg open.
    Then I would like to run a command from A.dwg to go a list consisting of all these drawings ("A.dwg" "B.dwg" "C.dwg"). Is it possible?

  7. #7
    Login to Give a bone
    0

    Default Re: list all open drawings?

    Please review these two attachments. They may need some other files. I don't know right now, because I'm on a short break at work responding to this.
    Try it and see if it works for you. Just open the LISP files and scroll through it to get and idea of what it does.
    The first time you run a VBA for AutoCAD macro the dialog in the attachment named "AutoCAD VBA Macros.jpg" will be displayed.
    I always uncheck the [ ] for Always ask before opening projects with macros, so I don't see this again.
    A simple test of the program is to zoom in on some detail in three different drawings.
    Load "OpenDwgsCmds" in each drawing if you haven't included it in your AcadDoc.lsp file.
    Then on the command line in one drawings type the following.
    Command:
    ODC
    Zoom
    E
    end
    And it zoom extents in all open drawings.
    You can run other LISP routines also using this idea.
    Terry
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by Terry Cadd; 2019-06-25 at 06:51 PM.

Similar Threads

  1. Open Drawings Tab
    By Wish List System in forum Revit Structure - Wish List
    Replies: 0
    Last Post: 2012-12-03, 03:51 PM
  2. Recent Open Files List in Open Dialog Box
    By inventor.wishlist1738 in forum Inventor Wish List
    Replies: 2
    Last Post: 2012-09-16, 07:10 PM
  3. Replies: 3
    Last Post: 2012-06-17, 09:42 PM
  4. Replies: 2
    Last Post: 2011-04-28, 02:04 AM
  5. Open Drawings
    By JeffClark in forum AutoCAD General
    Replies: 5
    Last Post: 2010-08-10, 03:56 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •