Macro: Export all open drawings as PDF and DWG

Library for macros
User avatar
gupta9665
Posts: 411
Joined: Thu Mar 11, 2021 10:20 am
Answers: 25
Location: India
x 434
x 450

Macro: Export all open drawings as PDF and DWG

Unread post by gupta9665 »

Attached is a macro to export all open drawings as PDF and DWG in the same location as the drawing file. The macro has been made on SW 2019 version but should work on earlier versions as well. Changing the macro reference to your installed as suggested here Fix-Update SOLIDWORKS Macro References? (don't worry on the fact that video is for fixing missing library error but check the process to update your macro library).
Export Open Drawings as PDF_DWG (SW2019).zip
(12.85 KiB) Downloaded 1284 times
The macro would check for all open files and would process only drawing files. In case there is no file or no drawing file (will check only the drawings which has been saved), it would prompt the user.
1.jpg
4.jpg
If macro found a drawing then it would prompt user if he/she wants to export PDF & DWG both or only DWG.
3.jpg
If a drawing has not been saved ever, macro would skip that drawing and prompt the user. This would happen in case there is more than one open drawing and some of them have not been saved.
2.jpg
If there is no model view found in a drawing, macro would skip that drawing and prompt the user.
5.jpg
The exported PDF/DWG file name would be based on Part Number, Revision and Description custom properties values from the model. So make sure your model has these custom properties with values.

If you want to keep the same file name, then comment out the highlighted line and use the other line.
6.jpg

I'll be updating macro later to ask for a save location. Let me know what else you would like to get updated/added in the macro.
Deepak Gupta
SOLIDWORKS Consultant/Blogger
User avatar
Ömür Tokman
Posts: 361
Joined: Sat Mar 13, 2021 3:49 am
Answers: 1
Location: İstanbul-Türkiye
x 994
x 347
Contact:

Re: Macro: Export all open drawings as PDF and DWG

Unread post by Ömür Tokman »

Big Master, you are perfect.
Thanks a lot
You ˹alone˺ we worship and You ˹alone˺ we ask for help.
User avatar
Conklin
Posts: 50
Joined: Fri Mar 26, 2021 3:34 pm
Answers: 0
x 10
x 21

Re: Macro: Export all open drawings as PDF and DWG

Unread post by Conklin »

Great Job

Please look at the attached "Batch_Save_As_DWG_Seprate_Shts.text"

It is perhaps not the best written/pieced together Macro
But
it works for me...


But, particularly look at the bit that: ( that I think is a good idea )
Saves all sheets of all the Files in a specified directory as DWG files. with " - SHT 01", " - SHT 02" etc....
' NOTE: If there is only one sheet it will leave off the " - SHT 01"

This is to get rid of the 00... 01... 02... 03... prefix
SW would assign when saving a multi sheet SW drawing to DWG as separate sheets
and will put a suffix in stead of " ...- SHT 01", " ...- SHT 02" etc..
only if there is more than one sheet.

And it also saves all the DWGs in an "AutoCad Batch Saved" folder


The last bit in the macro is just to WAKE me up when it is done!
Attachments
Batch_Save_As_DWG_Seprate_Shts.txt
(9.09 KiB) Downloaded 615 times
ghkdwkd007
Posts: 1
Joined: Thu May 18, 2023 11:34 pm
Answers: 0

Re: Macro: Export all open drawings as PDF and DWG

Unread post by ghkdwkd007 »

The post you posted helped me a lot. Thank you.
However, I am inquiring because there is a part that cannot be modified.
I couldn't find the part number in the part where I found the part number, so I went to the description and got the conversion name. I don't know how to solve this.
User avatar
gupta9665
Posts: 411
Joined: Thu Mar 11, 2021 10:20 am
Answers: 25
Location: India
x 434
x 450

Re: Macro: Export all open drawings as PDF and DWG

Unread post by gupta9665 »

ghkdwkd007 wrote: Thu May 18, 2023 11:40 pm The post you posted helped me a lot. Thank you.
However, I am inquiring because there is a part that cannot be modified.
I couldn't find the part number in the part where I found the part number, so I went to the description and got the conversion name. I don't know how to solve this.
I'm not able to understand your issue. Can you share your file and some images explaining the issue in more detail.
Deepak Gupta
SOLIDWORKS Consultant/Blogger
Post Reply