You’ll need to use IModelDoc2::GetTitle, or maybe IModelDoc2::GetPathName and parse out the file name. Search in the search bar at the bottom for “GetTitle” or “GetPathName” to see examples. There should be some free examples that show you how to use these. Or you can look in the API Help.
You could only create a single PDF by taking all of the individual PDFs and merging them into one. There is no option in SolidWorks or the SolidWorks API to do exactly what you’re describing.
IModelDocExtension::SaveAs is a newer API call that gives you more options that IDrawingDoc::SaveAs3. The latter should still work fine, though, as you discovered. If you find that it is simpler to use and suits your purposes, there’s nothing wrong with using it.
Hi keith,
Is there a way that the macro will ask where do i want to save the pdf, I Dont want to save it in the same location every time i run the code.
Ready to start learning the SolidWorks API? Sign up for FREE membership here.Keep up with new videos, macros, and training events by joining our mailing list:
is there any solution to switch of “view pdf after saving” via API?
Not that I am aware of. An enhancement request would probably be the way to go.
HI Keith
Is it possible to change and use the SW-File Name instead of “export”
You’ll need to use IModelDoc2::GetTitle, or maybe IModelDoc2::GetPathName and parse out the file name. Search in the search bar at the bottom for “GetTitle” or “GetPathName” to see examples. There should be some free examples that show you how to use these. Or you can look in the API Help.
Hi Keith,
Is it possible to have a single PDF for several drawing files located in a single folder?
You could only create a single PDF by taking all of the individual PDFs and merging them into one. There is no option in SolidWorks or the SolidWorks API to do exactly what you’re describing.
Hi. Could you tell me how this is different from using the SaveAs3 :
longstatus = swDraw.SaveAs3(“C:\” + Name + “.PDF”, 0, 0)
This call works and saves all sheets to a pdf in one go, creating bookmarks for all views
IModelDocExtension::SaveAs is a newer API call that gives you more options that IDrawingDoc::SaveAs3. The latter should still work fine, though, as you discovered. If you find that it is simpler to use and suits your purposes, there’s nothing wrong with using it.
Hi keith,
Is there a way that the macro will ask where do i want to save the pdf, I Dont want to save it in the same location every time i run the code.
You could incorporate a folder browser dialog, you would need to google how to do this in VBA. You could also use the InputBox() function.