Hello everyone,
We export drawings from our BIM software to DWG format. But according to drawing delivery requirements we need to post-process the DWG files in AutoCAD with the following routine:
This is repeated for every DWG file. In large projects with lots of drawings this is a very tedious process, as you can understand. We can not deviate from the delivary requirements because they are deeply intertwined with consultancy contracts here in Sweden.
It would be great if we could run a script in AutoCAD which performs this process on all DWG files in a folder.
Is it possible to automate this process with a script? If so, we would appreciate pointers. Prepared to spend some time on this matter.
Best regards,
Solved! Go to Solution.
Solved by hak_vz. Go to Solution.
Here is option using accoreconsole.exe
For a test create directory D:/test and copy to it some dwg file to process (for testing).
In that directory create batch file named "proc.bat" and change path to accoreconsole.exe in it according to your version.
echo off
:: Path to AutoCAD core console
set accoreexe="C:\Program Files\Autodesk\AutoCAD 2018\accoreconsole.exe"
:: Path the directory to process
set "source=D:\test"
:: Path to the script to run
set script="D:\test\proc.scr"
FOR /f "delims=" %%f IN ('dir /b "%source%\*.dwg"') DO %accoreexe% /i "%source%\%%f" /s %script%
pause
In same directory create script file named "proc.scr"
(setvar 'ctab "MODEL")
(load "d:\\test\\proc.lsp")
save ""
In same directory create lisp file named "proc.lsp". It may look something like this. I guess defaultformat for save is 60 but check . copy to acad console and run (getenv "DefaultFormatForSave") after ypu set default save format to version Acad 2013
(setvar 'cmdecho 0)
(command "_.-layer" "_set" "0" "")
(command "-zoom" "e")
(command "-purge" "All" "n" "" "")
(setenv "DefaultFormatForSave" "60")
(setvar 'cmdecho 1)
(princ)
In lisp file append command options in accordance wit the version you use, by running command in console i.e. -layer -purge (repeat that row 2-3 times if necessary.
Run proc.bat to process dwg files in directory(folder) D:test. Always hold original files and process copies for safety reasons.
Miljenko Hatlak
Thank you for the eloborative suggestion and explanation. We will give this a try!
IMO the best way to clean a drawing imported from revit is to use the command -EXPORTTOAUTOCAD in conjunction with a script and not just PURGE all
Command: -EXPORTTOAUTOCAD
File format: 2018
Bind xrefs: Yes
Bind type: Insert
Filename prefix: ACAD-
Filename suffix:
Export options [Format/Bind/bind Type/Maintain/Prefix/Suffix/?] <Enter for filename>: F
Enter file format [r14/2000/2004/2007/2010/2013/2018] <2013>:
Export options [Format/Bind/bind Type/Maintain/Prefix/Suffix/?] <Enter for filename>:
Use this - AutoRunLisp
Most of that can be handled through DWGConvert in AutoCAD, or even TrueView. Look into the conversion options, there are settings for purge, importing named page set-ups, set default printer to 'none', and AUDIT.
This method turned out to work exactly as I wanted, thanks! I reworked your method/code to fit my needs. Thought I might share my solution for other forum visitors to find. It relies on two files: one .bat file and one .scr file.
The files automate this process:
Here's how I use it.
DwgExportPostProcessingExecutable.bat
echo on
:: Path to AutoCAD core console
set accoreexe="C:\Program Files\Autodesk\AutoCAD 2018\accoreconsole.exe"
:: Path the directory to process
set "source=%CD%"
:: Path to the script to run
set script="%CD%\DwgExportPostProcessingScript.scr"
FOR /f "delims=" %%f IN ('dir /b "%source%\*.dwg"') DO %accoreexe% /i "%source%\%%f" /s %script%
pause
DwgExportPostProcessingScript.scr
(setvar 'cmdecho 0)
(setvar 'ctab "MODEL")
(command "zoom" "e")
(command "_.-layer" "_set" "0" "")
; Triple purge just to be sure
(command "-purge" "All" "*" "N" "")
(command "-purge" "All" "*" "N" "")
(command "-purge" "All" "*" "N" "")
; DefaultFormat 60 equals saving as AutoCAD 2013 DWG
(setenv "DefaultFormatForSave" "60")
(setvar 'cmdecho 0)
(princ)
(command "_.save" "" "Y")
; Important to end script with linebreak below this last comment
Can't find what you're looking for? Ask the community or share your knowledge.