Hey all,
Working for a company who wants a macro they can use to save a large number of drawings from a SolidWorks PDM as individual PDFs in the same folder location. It shouldn't replace the files just save as the same name with .pdf for each sheet. Here is what we have so far, I got it from another forum. It runs and saves the sheets but we cannot find where they are going. I've looked for folder location macros but Im pretty new at this and don't really know what im doing. Any help is greatly appreciated. Thanks.
-Dennis
Dennis,
No path is set in the macro, so it is saving in the last folder you accessed in Solidworks.
You need a way to isolate out the original file name from swModel.GetPathName
I'm guessing every sheet name is unique to every drawing or else you'll continuously overwrite your files.
I would do something like:
Set swDraw = swModel
Set swSheet = swDraw.GetCurrentSheet
swModel.GetPathName
SumPath = swModel.GetPathName
PathName = Len(swModel.GetPathName) - 7
swFile = Left(swModel.GetPathName, PathName)
vSheetNameArr = swDraw.GetSheetNames
For Each vSheetName In vSheetNameArr
bRet = swDraw.ActivateSheet(vSheetName): Debug.Assert bRet
swDraw.ViewZoomtofit2
Set swExportPDFData = swApp.GetExportFileData(1)
swExportPDFData.SetSheets swExportData_ExportSpecifiedSheets, vSheetName
swModel.Extension.SaveAs swFile & "_" & vSheetName + ".PDF", 0, 0, swExportPDFData, lErrors, lWarnings
Next vSheetName
swApp.CloseAllDocuments True
This appends the sheet name to the end of the original filename with an underscore in between.
Might not be what you are looking for exactly, but should point you in the right direction.