Is there a way to get a list of all the drawings that are currently open using lisp?
|
|
|
Is there a way to get a list of all the drawings that are currently open using lisp?
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 |
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.
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?
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
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?
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
Last edited by Terry Cadd; 2019-06-25 at 06:51 PM.