How to save SW drawings to PDF in bulk?

Hello all,

I'm having a problem to save the SW drawings to PDF in bulk. Hope you can help me.
Apologies if I'm explaining it in too much detail.
So the problem goes like this:

Consider I have a couple of SW files in a folder with all the assembly, part and drawing files, so I need to save the drawings to PDF and so far I had to do it manually by opening up each file and saving it to pdf.

Later on, I got a macro to save the drawings to pdf and I have added it to my toolbar but still I have to open up the drawing then click the macro button.

Well I want to automate this entire process. I know it can be done with Task Scheduler but there are some problems I'm facing with the task scheduler as well :

1. Task Scheduler Print Command

First way to saving the drawings to PDF is print them using a PDF printer (like Adobe Acrobat) through Task scheduler.

Problem. : I use A2 paper size for my drawings and I can't get A2 in the print setup of task scheduler. I made every change in control panel > printer properties but it is still not showing A2 paper size in Task scheduler Print setup options

2. Running a custom task in Task scheduler

Well I think we can run a Macro using "run custom task" which will then save the PDF files in bulk.

Problem: I have a pdf macro (which I explained in the beginning) but that doesn't let me perform such action in bulk using "run custom task".

I'm new to macros and not sure how to write such a macro which can perform this action.

Your help is much appreciated.

Thanks all in advance.

Ashish

4 Answer

You could do that in SW task scheduler
- Select Export files
- Select Export file type as PDF
- Add files that have to be saved as PDF/ folders that contain the drawings and click on Finish
Hope this helps :)

Hi,
I have got the same question as you, Have you got a macro yet?
If so, please let me know, I would like it as well
regards

See attached file to print all SLDDRW files in a directory to PDF.
You need to edit the macro to change the directory where it looks for the SLDDRW files.

' ******************************************************************************
' Use a print-to-pdf driver such as foxit. That you can setup in such a way
' that no user interaction is required (such as save directory, filename, overwrite, etc)
' when the printer driver gemerates the pdf
' ******************************************************************************

Sub printFile(filename)

Dim swApp As Object
Dim longstatus As Long, longwarnings As Long
Dim Part As Object
Dim swDrawing As DrawingDoc

Set swApp = Application.SldWorks
Set Part = swApp.OpenDoc6(filename, 3, 0, "", longstatus, longwarnings)

Set swDrawing = Part
Set Part = swApp.ActiveDoc
Dim myModelView As Object
Set myModelView = Part.ActiveView
myModelView.FrameLeft = 0
myModelView.FrameTop = 0
myModelView.FrameState = swWindowState_e.swWindowMaximized
Part.PrintDirect
swApp.CloseDoc (filename)

End Sub

Sub printAllDrawings()

Dim varDirectory As Variant
Dim flag As Boolean
Dim i As Integer
Dim strDirectory As String

strDirectory = "E:\eman\Documents\SolidWorks\ArcadeCabinetV4\"
varDirectory = Dir(strDirectory + "*.SLDDRW", vbNormal)

i = 1
flag = True

While flag = True
If varDirectory = "" Then
flag = False
Else
'MsgBox (strDirectory + varDirectory)
printFile (strDirectory + varDirectory)
'returns the next file or directory in the path
varDirectory = Dir
i = i + 1
End If
Wend

End Sub