CAD Forums => CAD General => Topic started by: CJ on March 12, 2024, 01:50:54 PM
Title: Scripting a method to close a DXF without Save As DWG dialog box
Post by: CJ on March 12, 2024, 01:50:54 PM
Hello everyone,
I have created a LISP routine that exports a DXF but now I want to open that DXF and run another function. What I want is to strip all the Object Data/XData from the DXF before I send the files to client. I do not want to run this function in my working DWG.
Everything I have read says that scripting is my best choice to open other DWGs from a current DWG, do something, close and move onto the next DWG. I currently have a Test LISP file (zoom extents) that I can load via a script file and run successfully. I have gotten the save the DWF to work. My script is failing at the point where it closes.
It seems that whenever I try to CLOSE a DXF, AutoCAD demands that confirm I do not want to save my work as a DWG, twice! I have tried the Filedia 0 but it doesn't help. I cannot find a 'silent' or command-line version that by-passes this dialog box.
Any help with this scripting issues would be great.
Title: Re: Scripting a method to close a DXF without Save As DWG dialog box
Post by: dexus on March 12, 2024, 04:06:20 PM
You can add this to your .scr file for closing the drawing:
Title: Re: Scripting a method to close a DXF without Save As DWG dialog box
Post by: 57gmc on March 12, 2024, 06:53:38 PM
As soon as you open the dxf, AutoCAD is going to convert it to a dwg. Don't re-open the dxf. Strip the object data from the dwg first, then export to dxf. This will leave the open dwg as a dxf. If you try to close now, you will be prompted to save as a dwg. Instead you can then close the dxf using
Title: Re: Scripting a method to close a DXF without Save As DWG dialog box
Post by: CJ on March 14, 2024, 04:52:24 PM
Thanks dexus and 57gmc for your input. After many hours of banging my head and keyboard I got the script to run but now i am struggling with a new issue. It was opening the second drawing ( I had the first two DXFs open in AutoCAD) then I got the save function working and now for some reason it will not open the second drawing on the list.
Here is the code. The CZA.lsp is just a sample code for zoom extents. Batchfileslist is a list of DXFs files in a folder.
Like I said before, the script can open the dxf file, do something to it and close it as a DXF. I probable have a small error somewhere that causing an error for opening the second.
Title: Re: Scripting a method to close a DXF without Save As DWG dialog box
Post by: 57gmc on March 14, 2024, 07:23:54 PM
I would just use "n" instead of "(nth acount batchfileslist)", as it is already evaluated and available. Calling it "n" might mislead you to think its a number, but its just an element in the list, the same as returned by "(nth n list)". I assume that n should be a valid filepath.