I am still learning lisp, I have a start on this one and I am looking for some help (I understand there are more than one ways to do this without lisp, but I am messing around to learn lisp). I have this code below that will save the current drawing thats open as a autocad 2000.dwg, then using the "AEnext" command it goes to the next drawing. What I am looking to do is create a loop that will do this throughout the drawing set. So if I have 20 drawings in my project, it does this 20 times. Here's my code:
(vl-load-com)
(defun c:a2 () (command "filedia" "0" "saveas" "2000" "" "yes")
(vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) "aenext\r") ;;go to next drawing
)
Any help would be awesome. Thanks,
Solved! Go to Solution.
hrmm well i would first try experimenting with a "while" loop:
(vl-load-com) (defun c:a2 () (while (= 1 (getvar "cmdactive"))[/color] (command "filedia" "0" "saveas" "2000" "" "yes") (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) "aenext\r") ;;go to next drawing ) )
but i dont think it will be that easty, maybe a second lisp to work, something like this?
(defun c:a1) (while (= 1 (getvar "cmdactive")) (command a2) ) )
so what that may do is look for a command being run (a2) and continue repeating that until you escape or "a2" stops by itself. However, i've not had much success with this loop, so it will take some experimenting, have fun!
Hi,
It's easy! I prepared it in my autocad via my own 3 icon: (LIST, PREV, NEXT)
make a text file that contains all of drawings in current folder.
you can prepare Lisp code or just use DOS command to create this list:
DIR *.DWG /b/on > list.txt
Now, you can prepare NEXT or PREV command, for example PREV command should be:
(defun C:PREV() (setq ph (getvar "dwgprefix")) (setq ls (open (strcat ph "list.txt") "r")) (setq dwg (strcase (getvar "dwgname"))) (setq ls1 dwg) (setq w "t") (while w (setq ls2 ls1) (setq ls1 (strcase (read-line ls))) (if (= ls1 dwg)(setq w nil)) ) (close ls) (command "zoom" "e") (command "QSAVE") (command "open" (strcat ph ls2)) )
so, you can make three icon on your own Toolbar for list maker, next dwg and prev dwg to easy navigation!
(be sure about SDI=1)
Abbas
and also, you can use SCRIPT PRO free software by AutoDesk or even "DWG TrueView" to batch conversion to any dwg format or dwf or pdf.
Abbas