Jump to content
kArThIcK hAcKeR

Mass convert dwg to dxf

Recommended Posts

kArThIcK hAcKeR

Hello, everyone.

 

I get 50 DWG Drawings per day and i had to convert it to dxf.:popcorn:

 

So i made a little lisp to automate the conversion process.

 

LISP:

(defun c:s()
(command "dxfout")
(command "")
(command "16")
(command "regen")
(command "_close" "y")
)

Now that i have this lisp i'll drag all the 50 dwg's to autocad for opening them and then i'll have to press "s" 50 times. 8)

 

Now pressing "s" 50 times is the irritating part.:itsover:

 

Can somebody help me to mass save the document without having to open the document and pressing "s" 50 times!!!:huh:

Share this post


Link to post
Share on other sites
Lee Mac

  • Add the following code to your ACADDOC.lsp:
    (defun todxf ( ) (command "_.dxfout" "" "16" "_.regen" "_.close" "_Y"))


 

  • Open a new drawing.

 

 

  • Enter the following as the 'Script Line':
    _.open *file* (todxf)


 

  • Choose a directory of drawings to process (and whether or not to include subdirectories).

 

  • Run the program.

Share this post


Link to post
Share on other sites
dbroada

I was about to recommend you look on Lee Mac's site for a script writer program that will allow you to do this so of task quite simply. However, I did a refresh before posting and see he has beaten me to it.

Share this post


Link to post
Share on other sites
kArThIcK hAcKeR

It Opens Each and every document,

during the process i am unable to minimize the autocad, and the autocad pops up above all the other softwares; Not what i expected, but it works!!!

:D

thanks Lee

BTW

how do i mark this post as solved?

Share this post


Link to post
Share on other sites
Lee Mac
It Opens Each and every document, during the process i am unable to minimize the autocad, and the autocad pops up above all the other softwares; Not what i expected, but it works!!!

 

I'm guessing you haven't run a script before ;)

 

how do i mark this post as solved?

 

This forum unfortunately doesn't offer that option.

Share this post


Link to post
Share on other sites
kArThIcK hAcKeR

Yes, i have never wrote any scripts b4.

i thought that lisp is powerfull than script thats why.

:)

Any ways thanks for the immediate reply lee,

 

:roll:(BTW, i am the same karthik who contacted you for Copy to drawings and bfind.lsp)

Share this post


Link to post
Share on other sites
Lee Mac
i thought that lisp is powerfull than script thats why.

 

LISP is indeed far more powerful than an AutoCAD Script (which is simply a list of commands to be successively executed at the AutoCAD command-line), however, since both the AutoLISP & Visual LISP APIs run within the document namespace, they can only operate on the active drawing (with the exception of an ObjectDBX interface); whereas a Script provides a means to consecutively open and close a set of drawings, allowing batch processing.

 

I tend to use AutoCAD Scripts purely to open, save & close drawings for batch processing - after the drawing has been opened, I will perform all operations using a more powerful and robust AutoLISP program, before the Script then saves & closes the drawing. This way, one can exploit the batch processing ability of an AutoCAD Script, whilst making use of the superior power & error trapping afforded by AutoLISP.

Share this post


Link to post
Share on other sites
dbroada
I tend to use AutoCAD Scripts purely to open, save & close drawings for batch processing - after the drawing has been opened, I will perform all operations using a more powerful and robust AutoLISP program, before the Script then saves & closes the drawing. This way, one can exploit the batch processing ability of an AutoCAD Script, whilst making use of the superior power & error trapping afforded by AutoLISP.
I use scripts far more than Lee does, mostly as I am far less able in LISP than Lee but the BIG problem with scripts, as Lee points out, is their inability to trap errors. If an error occurs within a script AutoCAD will continue to accept input from the script as though it were being typed at the keyboard. This usually just results in the script never supplying a correct answer to any of the promps and the scripts will get to the end never having performed any actions. However occassionaly by coincidence a valid response is received with disasterous consequences. However, within their limitations, scripts are a powerful and underutilsed tool.

Share this post


Link to post
Share on other sites
Bill Tillman

dbroada makes a very good point. I did a batch operation not too long ago with LISP and it worked very well. I would recommend that you make a scratch copy of the folder(files) you want to work with and work on that copy with your script or LISP program. That way if something goes wrong you've got the originals intact. Remember, to err is human, but to really foul things up it takes a computer.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×