Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AutoCAD 2002 script file trouble

Status
Not open for further replies.

zeke79

Petroleum
Jan 14, 2003
16
0
0
US
i done a search and did not come up with an answer so i am going to ask.

I am not to familiar with script files and i'm trying to create a script that will allow me to open an AutoCAD 2002 drawing and save it as r14 then close. This much i have accomplished, the problem is i would like it to automatically run through a directory i have selected without writing all of the file names to script as there are about 12,000 files, or possibly a way to link to a text file to accomplish this?? i cannot use any outside software from the company i work because that all has to be tested for months before we can use it. an example would be
open
Q:\drawings.dwg
Q:\drawings.dwg
saveas
r14
yes

i just cannot get the script to complete with successive drawing listed as above and as i stated above i cannot write all that for each of the 12,000 plus drawings.

please help!!!!!!!!!!

 
Replies continue below

Recommended for you

Try setting SDI to 1 and then run the script. This is "single document mode" so it will unload one file when the next loads (or something like that).
 
i tried that, the problem lies in the script writing. i dont know how to get it to open multiple drawings without writing:
open
q:\drawing.dwg
saveas
r14
y
close

12,000 times. if anyone has a script file or any other way of doing it without installing programs, please help me out!
 
This should get you most of the way. Load this as a single LISP routine, then run GET_FILES and then CONVERTALL will run the script. Good Luck.


(defun C:GET_FILES ()
(prompt "\nChoose dwg file in directory")
(setq DIR (getfiled "Script Utility" "" "dwg" 4)
DIR (REMOVE_PATH DIR)
)
(command "SHELL"
(strcat "dir \"" DIR "*.dwg\" > c:\\dwg.dir /b")
)
)

(defun C:CONVERTALL (/ F1) ; start dir f1 f2 rl CNT dirs)
(setvar "CMDECHO" 0)
(setq F2 (open "c:\\convert.scr" "w"))
(close F2)
(setq F1 (open "c:\\dwg.dir" "r")
F2 (open "c:\\convert.scr" "w")
)
(setq CNT 1
DIRS DIR
)
;add extra "\\" for script file
(repeat (strlen DIRS)
(if (= (substr DIRS CNT 1) "\\")
(setq DIRS (strcat (substr DIRS 1 CNT)
"\\"
(substr DIRS (1+ CNT) (strlen DIRS))
)
CNT (1+ CNT)
)
)
(setq CNT (1+ CNT))
)
(while (setq RL (read-line F1))
(setq FILE (substr RL 1 (- (strlen RL) 4))) ; removes ".dwg"
(WRITESCRIPT FILE)
)
(princ "\nNew Y " F2)
(princ "\nConversion_Completed" F2)
(close F1)
(close F2)
(command "_.SCRIPT" "C:\\convert")
(setvar "cmdecho" 1)
(princ "\nComplete...")
(prin1)
)

(defun REMOVE_PATH (FILE)
(while (/= (substr FILE (strlen FILE) 1) "\\")
(setq FILE (substr FILE 1 (1- (strlen FILE))))
)
FILE
)

(defun WRITESCRIPT (FILE)
(princ "open Y" F2)
(princ (strcat "\n\"" DIR FILE "\"") F2)
(princ "\n(load \"convert\")" F2)
(princ "\nMyProgram\n" F2)
)


;;-----------------------------------------------------------------------------
;;Main portion of the program
;;-----------------------------------------------------------------------------
(defun C:MyProgram ()
(princ "\nComplete")
(prin1)
)
 
ok, now my problem is that the above lisp routine is saving every drawing as y. i need to keep the original file names due to our filing system. also this routine is only opening the first file on the script and then instead of using command open, "file.dwg" it just enters the drawing name on the command line. i am sorry about being so ignorant on this subject, i have only been learning lisp programming for about a month. i volunteered for the department to learn this and now i am being bombed by everyone for these "little fixes".
 
Zeke79,

Do you want to overwrite your existing drawings
with the saveas R14 drawings?

I have a compiled lisp file that open/plots an existing drawing. I've used this routine in R12 for unattended batch plotting. I could tweak this to open/saveas R14.

I could send you a copy of the program (compiled).
Email me at grevark@aol.com.
 
Estassoc,
yes, i want to overwrite existing dwgs with r14 format. i dropped you an email, if you dont receive it you can mail me at n.zakowski@mchsi.com.

Admiralken,
i do not have the migration assistant so i cannot use the batch conversion tool.

 
ok guys, i am still having no luck. i am getting an error message when the lisp routine is doing its thing. could this be due to the fact that these files are stored on a network drive? also my autocad 2002 is a network version, could this be part of the problem? i am at my wits end on this one.
 
Check out the following site for a programme called Hurricane.

This utility is allows you to create script files to process
if you are using Autocad 14, 2000+ & Lt versions. I use the product all the time for large volume drawing production. There are a number of templates and wizard scripts to help you, as well as the facility to create your own. You simply create the script then apply it to as many drawings as you want, the script runs with each drawing being opened,processed then saved/closed.
A must for all productive cad users who want to avoid repetitive tasks.
Regards

Graham Dury
Desco Ltd - England
 
Status
Not open for further replies.
Back
Top