Here is my line of code.
The pdf still opens even with the silent option.
boolstatus = swModelDocExt.SaveAs(PdfFilePath, 0, swSaveAsOptions_e.swSaveAsOptions_Silent, swExportPDFData, lErrors, lWarnings)
Recommendations?
I have discovered the reason.
I did a save as through Solidworks UI and noticed a check box. "View PDF after saving" I deselected this and pdf no longer pops up.
I guess the API silent option is overridden by the Save as Checkbox.
Message was edited by: Lyndon Crossman
SolidworksApi macros
I never seen PDF opening using this method. Can you post the complete codes to test.
Hi Lyndon
Have you found a way to toggle this option from withing the Program?
dudi
No I haven't found a way to toggle this via API.
Only values I have found are
http://help.solidworks.com/2013/English/api/swconst/filesaveaspdfoptions.htm
same problem here? is there any solution to switch of "view pdf after saving" via API?
Submit an enhancement request. This can be done in the customer portal. This is a simple enhancement so I don't think they would have a problem implementing it. I have had API-related ER's fulfilled with an year, so don't think the request is going to fall on deaf ears.
Keith
Video Tutorials for the SolidWorks API
hi Joerg
there is a registry dword that take care of that
"HKEY_CURRENT_USER\Software\SolidWorks\SolidWorks 2012\Export Settings\View PDF After Saving"
value of 1 means to open and 0 notto open
so you can use API to set that value if care to mess with the registry
David, I'm afraid that isn't a viable workaround because SolidWorks loads the export settings from the registry on startup and then saves them on shutdown. Consequently, even if the macro does modify this key before calling IModelDocExtension::SaveAs, the setting will still be equivalent to whatever was present on startup. To prove this:
1. Look at HKEY_CURRENT_USER\Software\SolidWorks\SolidWorks 2012\Export Settings\View PDF After Saving before opening SolidWorks
2. Open SolidWorks
3. Change HKEY_CURRENT_USER\Software\SolidWorks\SolidWorks 2012\Export Settings\View PDF After Saving to a 1 if 0, and a 0 if 1
4. Close SolidWorks
5. After refreshing the registry, look at HKEY_CURRENT_USER\Software\SolidWorks\SolidWorks 2012\Export Settings\View PDF After Saving. Notice that it is still the same value as in step 1.
Keith
Video Tutorials for the SolidWorks API
You might also just email the API support team directly and ask them. I had a similar problem recently with a system option that I needed to change, and they were able to send me some code to update the option even though there wasn't an API call for that specific option.
You can email them at apisupport@solidworks.com.
Hi keith
Yes You are right .
We change this setting before solidworks is up (solidworks is started by an external program).
However if the user change this setting during session, batch printing wont work the same
so users are told not to use this option.
in general we are using win2pdf as our prime pdf printing tool and there we have control of viewing within the api.
there are some prints in which we need better control of line width (in printing block) we then have to use save as pdf
and since its done for numerous drawing at onece it better to keep this option uncheked.
so this is not an optimum solution . it is as good as it gets until we have an spr
dudi
Someone generated an spr (622307) that submits this as a bug.
I'll submit an enhancement request as well since I've been meaning to add a control to our printing program that can toggle this. It seems like it would fit in the swUserPreferenceToggle_e Enumeration.
-Jason S.
Its simple. To stop this occuring do the following steps.
1) Open any drawing
2) File --> Save as --> [Save as type] PDF -->
3) In this screen, you can see a check box saying "View PDF after saving"
4) uncheck this box and then click save.. I repeat click save or it will revert to its state.
Voila the PDF will not open again when you Check-in..
Hi,
old bug in API still around, shame on SW!
Anyway, I was wondering why my add-ins A works but B doesn't....there's a difference:
This opens PDF:
boo = swModelDocExt.SaveAs(path & ".pdf", 0, 0, 0, e, w)
This does not:
boo = swModelDocExt.SaveAs(path & ".pdf", 0, 0, Nothing, e, w)
Just a workaround I guess, but I hope this helps!
br
Markku
www.sloworks.fi
Try setting up the PDF Export Data: (Taken from the Save File as PDF Example)
Set swExportPDFData = swApp.GetExportFileData(1)
swExportPDFData.ViewPdfAfterSaving = False
boolstatus = swModelDocExt.SaveAs(filename, 0, 0, swExportPDFData, lErrors, lWarnings)
thanks
At last it is fixed