Working on multiple

04Cad-Manager

Usenet Archive
Joined
Aug 14, 2003
Messages
1
Reaction score
0
I am working on a lisp to perform several functions on multiple open drawings (one at a time) then save the drawing, close it and move along to the next drawing. I have figured out the functions, but my code only works on the current drawing, modifying, saving, and closing it. (This is a MDI mode routine only) I am still learning visual lisp, I apologize in advance. I have attached the starting of the code any help is appreciated!

3-problems I can see (thus far):
1) The code is not stepping into the 2nd drawing as it should
2) closing default "drawing1" etc always asks for a "saveas" , DWGPREFIX, DWGTITLED, SAVENAME, DBMOD all have values so how can I filter the default drawing out unless I start the lisp w/ it closed?
3) Not sure how to handle the last drawing open..

Any help to get me to the next step would be helpful. Thanks in advance.

Thanks,
Curtis

(vlax-for dwg (vla-get-documents (vlax-get-acad-object)) (if (/= 0 (vlax-variant-value (vla-getvariable dwg "DBMOD"))) ;True only if the dwg has been modified... (PROGN (setq currentdwg (vla-get-activedocument (vlax-get-acad-object))) ;set current dwg to be modified (if (/= nil previousname) ;Was there a previous drawing (progn (command "close" previousname) ;(vla-close previousname (vlax-make-variant :vlax-false)) ;Close previous drawing <PROBLEMS?> ) (progn (setq titled (= 1 (vlax-variant-value (vla-getvariable dwg "DWGTITLED"))) name (if titled ; Name idrawing name as follows:
(vlax-get dwg "fullname")
; True=> get full name/path"
(vlax-variant-value (vla-getvariable dwg
"DWGNAME")) ; False=> get name only
)
)
(saveDwg dwg) ; goto "saveDwg" function
taking dwg variable
(setq previousname name) ; set previousname to curent open drawing and goto next for:
)
)
)
)
(acet-error-restore)
(princ)
)
 
You can't make lisp directly operate on more than the current DWG. If you HAVE to do multiple DWG's you often write a lisp routine which writes a script file which opens the relevant DWG and loads and runs the required routine and saves. The script file usually looks something like

open
dwg1
(load "mylisp")
mylisp
save
open
dwg2
(load "mylisp")
mylisp
save

etc

The run this script. I f you temporarily set AutoCAD to single document mode it stops you have a zillion files open simultaneously.
 

Latest threads

Back
Top