Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

some help would be nice

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
gcsjlewis
438 Views, 3 Replies

some help would be nice

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,

3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: gcsjlewis

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!

Message 3 of 4
aqdam1978
in reply to: gcsjlewis

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

 

Message 4 of 4
aqdam1978
in reply to: gcsjlewis

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

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost