Publish or print files automatically every month

Publish or print files automatically every month

joh.richard
Enthusiast Enthusiast
2,100 Views
8 Replies
Message 1 of 9

Publish or print files automatically every month

joh.richard
Enthusiast
Enthusiast

Hello, I have ~400 files that I want to automatically convert to PDF every month. I currently create a .DSD file to run a publish. I would like printing to be automatic every 1st of the month at 2am. I tried the automatic publish  in the options, but it did not meet my needs. Has anyone done something similar before?

Thanks

0 Likes
Accepted solutions (1)
2,101 Views
8 Replies
Replies (8)
Message 2 of 9

Ed__Jobe
Mentor
Mentor

You might try the Windows Task Scheduler (type it in the Cortana search bar). You can create a script that does what you want in AutoCAD or even ScriptPro and then use AutoCAD's command line switch /b to run the script. Then create a task in task scheduler to run it.

 

Also, if you have Bluebeam, you can create a batch job file and run that in Task Scheduler.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

Message 3 of 9

maratovich
Advisor
Advisor

Maybe you will like this - Revers 
You can specify a folder with your files and start automatic printing.

---------------------------------------------------------------------
Software development
Automatic creation layouts and viewport. Batch printing drawings from model.
www.kdmsoft.net
Message 4 of 9

Ed__Jobe
Mentor
Mentor

@maratovich That program doesn't appear to support scheduling of batch jobs. He doesn't want to come in a 2 am to start the batch.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

Message 5 of 9

joh.richard
Enthusiast
Enthusiast
Thank you very much for your suggestions. I will test your suggestions and get back to you with what works best.
0 Likes
Message 6 of 9

joh.richard
Enthusiast
Enthusiast

The script and Script pro work well. But I don't know how to link them in task scheduler. I add a task. The task launches and asks which application it should open 😕

0 Likes
Message 7 of 9

Ed__Jobe
Mentor
Mentor
Accepted solution

When it says to choose, the words are "program/script". Use the second option. Create a DOS *.bat file using Notepad. ScriptPro's Help gives you a sample script and sample bat command.

Command Line Access

To run a series of ScriptPro 2.0 projects from a DOS batch file,
you can use the ScriptPro command line interface:

<install dir>\ScriptPro <project name> "run"

For example:

C:\\ScriptPro 2.0\\ScriptPro.exe "c:\\TestProject.bpl" "run"

You can also use "exit" at the end to exit ScriptPro silently after 
processing the drawing list.

For example:

C:\\ScriptPro 2.0\\ScriptPro.exe "c:\\TestProject.bpl" "run" "exit"

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 8 of 9

joh.richard
Enthusiast
Enthusiast

I have a part of code in VBA for printing files in PDF

I would add a line to acaddoc.lsp to run this routine each time a specific file is opened.

I would add this specific drawing to task scheduler

It works almost perfectly. The drawings are printed, but not taking into account the printing specifications (size, CTB, rotation)
Could someone check my code and see where my error is? I guess it plotConfig the problem
Thank you

 

Public Sub DoPdfPlot()
    Dim backPlot As Integer
    Dim fileNames() As String
    Dim oPath As String
    Dim dPath As String
    Dim plotter As String
 
    'Setting background plot variable
    backPlot = ThisDrawing.GetVariable("BACKGROUNDPLOT")
    ThisDrawing.SetVariable "BACKGROUNDPLOT", 0
    
    
    'Original path -> Where DWG are
    oPath = "C:\Temp\architecture\"
    'Destination path -> Where PDF go
    dPath = "C:\Temp\architecture\pdf\"
    
    fileNames = GetFileNames(oPath)
    Dim fName As String

    Dim pdfName As String
    Dim dwg As AcadDocument
    Dim i As Integer
    For i = 0 To UBound(fileNames)
        fName = fileNames(i)
        
        Dim splitedFileName() As String
        Dim brutName As String
        
        ''Name de PDF "[DWGName].pdf"
        splitedFileName = Split(fName, ".")
        brutName = splitedFileName(0)
        
        pdfName = dPath & brutName & ".pdf" ''Determine PDF name based on DWG file name
        Set dwg = AcadApplication.Documents.Open(fName)
        PlotToPdf dwg, pdfName
        dwg.Close False
    Next
    ThisDrawing.SetVariable "BACKGROUNDPLOT", backPlot
End Sub

Private Function GetFileNames(path As String) As String()
    
    Dim fileNames() As String
    Dim i As Integer
    Dim file As String
    ''Get all DWG file from the Original Path
    file = Dir(path & "*.dwg")

    While file <> ""
        ReDim Preserve fileNames(i)
        fileNames(i) = file
        i = i + 1
        file = Dir
    Wend

    GetFileNames = fileNames
End Function

Private Sub PlotToPdf(dwg As AcadDocument, pdfFile As String)

    
    Dim ptObj As AcadPlot
    Dim ptConfigs As AcadPlotConfigurations
    Dim plotConfig As AcadPlotConfiguration
    Dim canonicalName As String
    
    'Create a new plot configuration with all needed parameters
    Set ptObj = dwg.Plot
    Set ptConfigs = dwg.PlotConfigurations

    'Add a new plot configuration
    Set plotConfig = ptConfigs.Add("PDF", True)
    
    plotConfig.ConfigName = "AutoCAD PDF (Web and Mobile).pc3"
    plotConfig.UseStandardScale = False
    plotConfig.StandardScale = acScaleToFit
    plotConfig.PlotRotation = ac0degrees
    plotConfig.PlotType = acExtents
    plotConfig.CanonicalMediaName = "UserDefinedImperial (48.00 x 36.00Inches)"
    plotConfig.CenterPlot = True
    plotConfig.StyleSheet = "C:\Users\KI-0052-SI\AppData\Roaming\Autodesk\AutoCAD 2021\R24.0\enu\Plotters\Plot Styles\Acad.ctb"
    plotConfig.PlotWithPlotStyles = True


    'Updates the plot
    plotConfig.RefreshPlotDeviceInfo
    
    
    Dim success As Boolean
    success = ptObj.PlotToFile(pdfFile, plotConfig.ConfigName)

End Sub

 

0 Likes
Message 9 of 9

joh.richard
Enthusiast
Enthusiast

Thank you so much @Ed__Jobe  it finaly work! 😁

I forgotten a " after run

0 Likes