×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

AutoCAD 2002 script file trouble

AutoCAD 2002 script file trouble

AutoCAD 2002 script file trouble

(OP)
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!!!!!!!!!!

RE: AutoCAD 2002 script file trouble

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).

RE: AutoCAD 2002 script file trouble

(OP)
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!

RE: AutoCAD 2002 script file trouble

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)
)

RE: AutoCAD 2002 script file trouble

(OP)
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".

RE: AutoCAD 2002 script file trouble

If you have the migration files from AutoCad 2000, you can use the batch conversion tool, works well, I have used it many times.

RE: AutoCAD 2002 script file trouble

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.    

RE: AutoCAD 2002 script file trouble

(OP)
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.

RE: AutoCAD 2002 script file trouble

(OP)
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.  

RE: AutoCAD 2002 script file trouble

Check out the following site for a programme called Hurricane.
http://www.74mph.com/howitworks.html

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources