plot multiple dwg-files (in different direcories) to pdf in multiple directories per cmd batchfile?

plot multiple dwg-files (in different direcories) to pdf in multiple directories per cmd batchfile?

Alexander_LindigETKK6
Participant Participant
2,128 Views
25 Replies
Message 1 of 26

plot multiple dwg-files (in different direcories) to pdf in multiple directories per cmd batchfile?

Alexander_LindigETKK6
Participant
Participant

Dear Community, 

 

I need your help.

 

With an older version of ACAD I was able to plot multiple dwg-files (source) to o muliple directories (target) per cmd batchfile. unfortunately I misplaced the batchfiles :-/.  

 

For each file was a line in the batchfile to plot it.

The comand looked simplyfied like that:

 

>> plot source dwg-file to target location pdf-file.

 

the Source files and target location are fix values so I do not need dynamic batch files.

 

Exemple Directories:

 

Source                                 Target

C:\CAD\drawingA.dwg >> X:\CAD-plan\PDF\drawingA.pdf

C:\CAD\drawingB.dwg >> Y:\Floorplan\PDF\drawingB.pdf

C:\CAD\drawingC.dwg  >> Z:\extern\PDF\drawingC.dwg  

 

Can somebody help? 

 

Thx Alex

 

PS: Batch Plot in ACAD doesn't seem the right solutions in this case.

0 Likes
Accepted solutions (4)
2,129 Views
25 Replies
Replies (25)
Message 2 of 26

pendean
Community Legend
Community Legend

That's never been a built-in AutoCAD ability: you previously used a custom LISP or 3rd party add-on.

Do you still have access to your old setup?

0 Likes
Message 3 of 26

baksconstructor
Advocate
Advocate

This can be done, but you will have to use add-ons.

0 Likes
Message 4 of 26

Alexander_LindigETKK6
Participant
Participant

Hi thx for the reply. 

 

No, unfortunately not. The old setup is lost. I know for sure it wasn't a 3rd party add-on. 

It was a very plain file. Probably a simple LISP.  At least the structure was simple. 

 

0 Likes
Message 5 of 26

TheCADnoob
Mentor
Mentor

Lots of ways to get this done. Here is one that users coreconsole and a vbs file. 

 

Create a text file called "BatchPrint.vbs" and put the following in it:

 

 

Dim fso, inputFile, line, fields, scriptFile, shell
Dim sourceFile, destinationFile, accoreConsolePath, tempScriptPath, scriptContent
Dim scriptDir, csvFilePath

' Initialize objects
Set fso = CreateObject("Scripting.FileSystemObject")
Set shell = CreateObject("WScript.Shell")

' Get the current directory of the VBScript file
scriptDir = fso.GetParentFolderName(WScript.ScriptFullName)
csvFilePath = fso.BuildPath(scriptDir, "Drawings.csv") ' CSV file in the same directory as the VBScript

' Check if the CSV file exists
If Not fso.FileExists(csvFilePath) Then
    WScript.Echo "Error: Drawings.csv not found in the current directory: " & scriptDir
    WScript.Quit
End If

' Open the CSV file
Set inputFile = fso.OpenTextFile(csvFilePath, 1) ' Read-only mode

' Read for accoreconsole.exe path and temporary .scr path
If Not inputFile.AtEndOfStream Then
    line = inputFile.ReadLine 'skip columns line
    line = inputFile.ReadLine
    fields = Split(line, ",")
    accoreConsolePath = fields(2) ' Third column: accoreconsole.exe path
    tempScriptPath = fields(3)    ' Fourth column: temporary .scr path

'WScript.Echo accoreConsolePath

    ' Validate paths
    If Not fso.FileExists(accoreConsolePath) Then
        WScript.Echo "Error: accoreconsole.exe not found at " & accoreConsolePath
        WScript.Quit
    End If
    If Not fso.FolderExists(fso.GetParentFolderName(tempScriptPath)) Then
        WScript.Echo "Error: Folder for temporary script does not exist: " & tempScriptPath
        WScript.Quit
    End If
Else
    WScript.Echo "Error: CSV file is empty or missing required paths."
    WScript.Quit
End If

' Loop through remaining lines 
Do Until inputFile.AtEndOfStream
    line = inputFile.ReadLine
    fields = Split(line, ",")
    sourceFile = fields(0)
    'WScript.Echo sourceFile
    destinationFile = fields(1)

    ' Generate the AutoCAD script content
    scriptContent = "OPEN """ & sourceFile & """" & vbCrLf & _
                    "-PLOT" & vbCrLf & _
                    "Y" & vbCrLf & _
                    "Model" & vbCrLf & _
                    "DWG to PDF.pc3" & vbCrLf & _
                    "ARCH expand D (24.00 x 36.00 Inches)" & vbCrLf & _
                    "Inches" & vbCrLf & _
                    "Landscape" & vbCrLf & _
                    "NO" & vbCrLf & _
                    "EXTENTS" & vbCrLf & _
                    "FIT" & vbCrLf & _
                    "CENTER" & vbCrLf & _
                    "NO" & vbCrLf & _
                    "" & vbCrLf & _
                    "Yes" & vbCrLf & _
                    "" & vbCrLf & _
                    """" & destinationFile & """" & vbCrLf & _
                    "NO" & vbCrLf & _
                    "YES" & vbCrLf & _
                    "CLOSE" & vbCrLf & _
                    "NO"

    ' Write the script to the specified temporary SCR file path
    Set scriptFile = fso.CreateTextFile(tempScriptPath, True)
    scriptFile.WriteLine scriptContent
    scriptFile.Close

    ' Run accoreconsole.exe
    'WScript.Echo """" & accoreConsolePath & """ /s """ & tempScriptPath & """"
    shell.Run """" & accoreConsolePath & """ /s """ & tempScriptPath & """", 1, True

    ' Delete the temporary SCR
    If fso.FileExists(tempScriptPath) Then fso.DeleteFile(tempScriptPath)
Loop

' Close file
inputFile.Close

' Done
WScript.Echo "Done"

 

 

 

 

Download the CVS file and put it in the same directory. 

 

TheCADnoob_0-1737996206029.png

 

 

Change the location of your files and path to acccoreconsole. the temp path is just a location where the VBS script creates a temporary AutoCAD .scr file with the specifics to your file. 

 

 

Once you have changed all your paths, close the CSV and then double click the vbs file. 

CADnoob

EESignature

0 Likes
Message 6 of 26

VincentSheehan
Advisor
Advisor

You could also write a script file to open and plot each DWG to PDF.

 

open
C:\CAD\drawingA.dwg
layout
set
(layout name)
-plot
no



X:\CAD-plan\PDF\drawingA.pdf
n
y
qsave
close
open
C:\CAD\drawingB.dwg
layout
set
(layout name)
-plot
no



Y:\Floorplan\PDF\drawingB.pdf
n
y
qsave
close
open
C:\CAD\drawingC.dwg
layout
set
(layout name)
-plot
no



Z:\extern\PDF\drawingC.dwg
n
y
qsave
close

 

 

Vincent Sheehan

Sr. Civil Designer
Poly In 3D Blog

Message 7 of 26

Alexander_LindigETKK6
Participant
Participant

Hi thx for the reply. the vbs-file is running without any error. But there is no pdf created. 

0 Likes
Message 8 of 26

Alexander_LindigETKK6
Participant
Participant

Hi Thx, I tried it but the script isnt running. via batch I run 

 

"C:\Program Files\Autodesk\AutoCAD 2025\accoreconsole.exe" /s "Y:\NOVA\CAD\PrintBatch\Code\scripttest.scr" /l en-US

 

But there is an error message: the loading of the file (script) was canceled. 

 

Alex

0 Likes
Message 9 of 26

baksconstructor
Advocate
Advocate

@Alexander_LindigETKK6 wrote:

Hi Thx, I tried it but the script isnt running. via batch I run 

 


Then there is another option:

 

33.PNG

0 Likes
Message 10 of 26

VincentSheehan
Advisor
Advisor

Are you plotting from model space or paper space? If paper space, did you change the layout tab names?

Vincent Sheehan

Sr. Civil Designer
Poly In 3D Blog

Message 11 of 26

Alexander_LindigETKK6
Participant
Participant

thx for the reply. 

 

I am plotting from paper space. I did change the Layout tab name (here was a spelling error).

Now the script starts but an error  >> unkown command "OPEN".  

 

Regards Alex

 

Alexander_LindigETKK6_0-1738073828639.png

 

0 Likes
Message 12 of 26

Alexander_LindigETKK6
Participant
Participant

Hi, thx for the reply. Nice option but, I can't use 3rd party tools :-/. 

Message 13 of 26

paullimapa
Mentor
Mentor
Accepted solution

Accoreconsole is definitely a very fast method to generate pdfs from dwgs. But there are a number of factors involved including providing the right sequence of commands and since you have different folder requirements to save the pdf you'll need multiple script files (see attached cmd batch file & script files)

PS: To learn more about accoreconsole:

Son of a Batch! AutoCAD Core Console Through Lisp | House of BIM


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 14 of 26

Alexander_LindigETKK6
Participant
Participant

Hi Paul,

thx for the reply. The script stops when it tries to load the *.scr File. Any Idea why the script doesn't load it? 

 

thx and regards Alex

 

Alexander_LindigETKK6_0-1738239357109.png

 

0 Likes
Message 15 of 26

VincentSheehan
Advisor
Advisor
Accepted solution

Try this. I tested with your file names and it works. I added Filedia to turn off and on. Don't forget to change the layout names. 

filedia
0
open
C:\CAD\drawingA.dwg
layout
set
(layout name)
-plot
no



X:\CAD-plan\PDF\drawingA.pdf
n
y
qsave
close
open
C:\CAD\drawingB.dwg
layout
set
(layout name)
-plot
no



Y:\Floorplan\PDF\drawingB.pdf
n
y
qsave
close
open
C:\CAD\drawingC.dwg
layout
set
(layout name)
-plot
no



Z:\extern\PDF\drawingC.pdf
n
y
qsave
filedia
1
close

 

Vincent Sheehan

Sr. Civil Designer
Poly In 3D Blog

Message 16 of 26

Alexander_LindigETKK6
Participant
Participant

Hi, thx for the reply,

 

1. the batch file has the code:

 

"C:\Program Files\Autodesk\AutoCAD 2025\accoreconsole.exe" /s "C:\temp\cad\scripttest.scr" /l en-US

 

2. the scripttest.scr file has the code:

 

filedia
0
open
"C:\temp\cad\20240209_MHD_EG.dwg"

layout
set
(layout A1_quer_M1-200)

-plot
no

 

"C:\temp\cad\pdf\MHD_EG.pdf"
n
y
qsave
filedia


1
close

 

2. the result when I run the batch file:

I still get the "unkown command "OPEN"" ("unbekannter Befehl "OPEN"") problem (s. red line)

Alexander_LindigETKK6_0-1738249166326.png

 

What am I doing wrong? Probably a beginner mistake :-/? 

 

thx and Best Regards Alex

 

0 Likes
Message 17 of 26

TheCADnoob
Mentor
Mentor
Accepted solution

if your scripts are not loading, make sure you add the location where the script will be to the trusted locations in AutoCAD. https://help.autodesk.com/view/ACD/2025/ENU/?guid=GUID-9C7E997D-28F8-4605-8583-09606610F26D

 

You should be able to add this in the options dialog

 

TheCADnoob_0-1738251952558.png

 

CADnoob

EESignature

0 Likes
Message 18 of 26

cadffm
Consultant
Consultant
Accepted solution

1. Filedia is useless, a Script is a automation where AutoCAD will use the commandline version, but it doesn't hurt.

2. German AutoCAD don't know about a command with name "OPEN",

    the german one is "öffnen", but for automation it is better you using international command&option calls: _OPEN

    (underline, followed by the englisch command or option name)

 

 

Sebastian

Message 19 of 26

cadffm
Consultant
Consultant

I am confused now

"C:\Program Files\Autodesk\AutoCAD 2025\accoreconsole.exe" /s "C:\temp\cad\scripttest.scr" /l en-US"

but it seems to start a german version!?

Sebastian

Message 20 of 26

TheCADnoob
Mentor
Mentor

EDIT: Looks liks @cadffm  beat me to it. 

 

It may be the language pack. Try adding a _ before the command

 

_open

 

https://help.autodesk.com/view/OARX/2024/ENU/?guid=GUID-D991386C-FBAA-4094-9FCB-AADD98ACD3EF

 

._CIRCLE; Starts the CIRCLE command, independent of the current AutoCAD language pack

CADnoob

EESignature

0 Likes