If you're looking for speed, try the AcCoreConsole (https://www.theswamp.org/index.php?topic=51181.0).
If you're looking for speed, try the AcCoreConsole (https://www.theswamp.org/index.php?topic=51181.0).Also recommend
I needed to do some batch processing of drawings today. I had never heard of "accoreconsole" (I got out of AutoCAD before it came about) but I followed the above link and I created a quick solution for myself this morning.This works great.
I created a batch script I can drag drawing files to to run a script on. The script file to run and the batch script are located in the same folder. Replace/fix the path as required (I only had AutoCAD 2018 installed on my laptop).
Batch Script: "BatchDrawings_accoreconsole.cmd"Code - Bash: [Select]
@echo off :: process files given as argument to this batch script. :: :: Last Updated: 04.14.20 9:41:00 AM :: :: BY: John Kaul set script="%~dp0\BatchDrawings_accoreconsole.scr" set script=%script:\\=\% :processArgs if [%1]==[] goto endmark call "C:\Program Files\Autodesk\AutoCAD 2018\accoreconsole.exe" /i "%~f1" /s %script% /l en-US if errorlevel 1 goto errormark SHIFT goto processArgs :errormark echo. echo. echo ERROR processing %~f1 pause echo. :endmark rem rem finished rem
Sample script: "BatchDrawings_accoreconsole.scr"
(Sample only, replace with what you want)Code - Auto/Visual Lisp: [Select]
(setq ERROR-LST- '("AUTOSNAP" "OSMODE" "APERTURE" "HPSPACE" "HPASSOC" "MIRRTEXT" "AUPREC" "LUPREC" "DIMZIN" "CECOLOR" "CLAYER" "CMDECHO" "FILEDIA" "OSMODE") );_end setq '( ;; --== ==-- ;; ;; ;; --== ==-- ;; audit the drawing ;; purge the drawing a ;few times (*error* "") ;; save ) ) ; mapcar ) )
Drag and drop the drawing files to the "BatchDrawings_accoreconsole.cmd" you want to process.
This works great.Thanks! Yes it does; I just scripted a 100 or so drawings this morning.
I created a PDF plotting script and setup a shortcut in windows SendTo menu.
copy "BatchDrawings_accoreconsole.cmd - Shortcut.lnk" "C:\Users\%username%\AppData\Roaming\Microsoft\Windows\SendTo"
(COMMAND "TILEMODE" "0")
(command "PSPACE")
(command "zoom" "e")
(command "zoom" "e" "regenall")
(setq extents (mapcar '- (getvar 'extmax) (getvar 'extmin))maxdim (apply 'max extents))
(setq maxdim (distance (list (car (getvar "extmin")) 0.0 0.0)
(list (car (getvar "extmax")) 0.0 0.0)))
(cond
((>= maxdim 47)
(setq myps (strcat "ARCH full bleed E "(chr 40) "36.00 x 48.00 Inches" (chr 41) "")))
((>= maxdim 40)
(setq myps (strcat "ARCH full bleed E1 "(chr 40)"30.00 x 42.00 Inches"(chr 41)"")))
((>= maxdim 34.5)
(setq myps (strcat "ARCH full bleed D "(chr 40)"36.00 x 24.00 Inches"(chr 41)"")))
((>= maxdim 32)
(setq myps (strcat "ANSI full bleed D " (chr 40) "22.00 x 34.00 Inches" (chr 41) "")))
((>= maxdim 11.5)
(setq myps (strcat "ANSI full bleed B " (chr 40) "11.00 x 17.00 Inches" (chr 41) "")))
((<= maxdim 11.49)
(setq myps (strcat "ANSI full bleed A " (chr 40) "8.50 x 11.00 Inches" (chr 41) ""))))
(setq LL (getvar 'extmin) UR (getvar 'extmax) )
(if (> (- (car UR) (car LL)) (- (cadr UR) (cadr LL)))
(setq myoren "landscape")
(setq myoren "portrait"))
(if (= myoren "portrait")
(progn
(setq extents (mapcar '- (getvar 'extmax) (getvar 'extmin)) maxdim (apply 'max extents))
(setq maxdim (distance (list (car (getvar "extmin")) 0.0 0.0)
(list (car (getvar "extmax")) 0.0 0.0)))
(cond
((> maxdim 10)
(setq myps (strcat "ANSI full bleed B "(chr 40)"11.00 x 17.00 Inches"(chr 41)""))))))
(acet-file-mkdir (strcat (getenv "UserProfile") "\\Desktop\\PDFs\\"))
-PLOT
y
DWG To PDF.pc3
(setq x myps)
Inches
(setq x myoren)
No
Extents
1:1
Center
Yes:
acad.ctb
Yes
Yes
No
No
(strcat (getenv "UserProfile") "\\Desktop\\PDFs\\" (cadr (fnsplitl (getvar 'dwgname))))
y
y
@echo off
:: process files given as argument to this batch script.
::
:: Last Updated: 04.14.20 9:41:00 AM
::
:: BY: John Kaul
::
set script="LEFT BLANK"
set script=%script:\\=\%
:processArgs
if [%1]==[] goto endmark
[color=red]title "%~f1"[/color]
call "C:\Program Files\Autodesk\AutoCAD 2021\accoreconsole.exe" /i "%~f1" /s %script% /l en-US >"C:\temp\cleanup.log"
if errorlevel 1 goto errormark
SHIFT
goto processArgs
:errormark
echo.
echo.
echo ERROR processing %~f1
pause
echo.
:endmark
rem
rem finished
rem
I added the red part above so it shows what file it is processing.if /I [%~x1]==[.DWG] (echo "[%count%/%argc%]: Processing... %~f1" ) else (echo "[%count%/%argc%] skipping %~f1" )
if /I [%~x1]==[.DWG] (call "C:\Program Files\Autodesk\AutoCAD 2021\accoreconsole.exe" /i "%~f1" /s %script% /l en-US >"C:\temp\cleanup.log")
Sorry, I didn't get around to addressing your previous post.John,
Nice script!
Your line #49 can be cleaned up a bit by using a separate function like the following:Code - Visual Basic: [Select]
Function getExtension(filespec) Dim fso Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.GetFile(filespec) getExtension = fso.GetExtensionName(filespec) End Function
Use like this:Code - Visual Basic: [Select]
If(UCase(getExtension(sFilePath))="DWG") Then 'proceed
I do not like line #39; would you be open to a bit of a restructure of the code block of lines 22-39?
You could add a SELECT CASE (-i.e. COND in autolisp) to do some prompting of misc errors and then eventually just quit the script after the for loop.
This seems to work:Code: [Select]if /I [%~x1]==[.DWG] (echo "[%count%/%argc%]: Processing... %~f1" ) else (echo "[%count%/%argc%] skipping %~f1" )
if /I [%~x1]==[.DWG] (call "C:\Program Files\Autodesk\AutoCAD 2021\accoreconsole.exe" /i "%~f1" /s %script% /l en-US >"C:\temp\cleanup.log")
There is one problem I found. If any of the file names or folders have the '&' character it doesn't work.
People who insist on using special characters in file names are a problem, not the names themselves. But I'm a little old school. :crazy2: