hi Andrew, i've been creating a small plugin with c# and i've implemented the same PDF Save Procedure. I hope this will help you:
public bool CreatePDF(out string errorMessage, out string warningMessage, SldWorks app, ModelDoc2 Drawing)
bool result = false;
errorMessage = "";
warningMessage = "";
int errors = 0;
int warnings = 0;
ExportPdfData swExportPDFData = default(ExportPdfData);
ModelDocExtension swModExt = default(ModelDocExtension);
string sourceFullPath = Drawing.GetPathName();
string newPdfFullFileName = Path.ChangeExtension(sourceFullPath, "pdf");
swModExt = (ModelDocExtension)Drawing.Extension;
swExportPDFData = (ExportPdfData)app.GetExportFileData((int)swExportDataFileType_e.swExportPdfData);
swExportPDFData.ViewPdfAfterSaving = false;
result = swModExt.SaveAs(newPdfFullFileName, (int)swSaveAsVersion_e.swSaveAsCurrentVersion, (int)(swSaveAsOptions_e.swSaveAsOptions_Silent | swSaveAsOptions_e.swSaveAsOptions_Copy), swExportPDFData, ref errors, ref warnings);
catch (Exception ex)
errorMessage = ex.ToString();
Thank you for the reply Michele, however I'm afraid I can't confirm that solution works, because something funky is going on with the visual studio package here.
In case anyone stumbles upon this I believe I've managed a rough solution within VBA. Because PDM Standard doesn't appear to support vault access/checking files out etc, I've come across a way of simply checking the write status of the PDF file destination before even attempting to save (thank you stack exchange!). I can then at least alert anyone using the macro the destination is locked and intervention is needed.
The code for this is the following:
Public Function isReadOnly(ByVal fName As String) As Boolean
'vbNormal = 0, vbReadOnly = 1, vbHidden = 2, vbDirectory = 16
If Len(fName) > 0 Then isReadOnly = GetAttr(fName) And vbReadOnly
This takes in the file location (i.e. C:\Folder\drawing.pdf) and returns true if the file is writable, then if the file isn't checked out/writable then this will return false.
If you think there is an issue with the API coding in solidworks you can email support and depending on the issue maybe able to help you out at email@example.com.
I know I use a macro for saving PDF and DXF files, and I use that same line of code, however I don't have issues but I also don't have PDM standard so I can't help there.