US$0.00
0

SolidWorks Macro to Batch Rebuild and Export Drawings to PDF

Description

The script will automatically rebuild all SolidWorks drawing files (.SLDDRW) in a user-specified Windows directory, assuring every view and annotation is up to date, and will immediately save each as a PDF file.

SolidWorks Macro to Batch Rebuild and Export Drawings to PDF and An image divided into two side-by-side sections labeled "Before" and "After," showing a SOLIDWORKS software interface. The "Before" section displays a sketch on the "Front Plane" with a simple rectangular outline and a single dimension line labeled "L." The feature tree on the left lists "Sketch1" under "Front Plane." The "After" section shows the same sketch transformed into a filled square with diagonal lines, now including dimension lines labeled "59.43" for the length and "60.0" for the width, and the same feature tree updated with "Sketch2." Both sections include toolbars and a 3D view with axes indicators.

System Requirements

  • SolidWorks Version: SolidWorks 2014 or newer
  • Operating System: Windows 10 or later
  • Excel Version: Microsoft Excel 2010 or later (for Excel integration features)

Pre-requisites

  • The macro code must have the absolute file path of the folder that contains the SolidWorks drawings before running the macro.
  • SolidWorks needs to be installed and open on the machine in order to run the macro.

Results

  • For each original SolidWorks drawing processed, a PDF file is created.
  • PDF files are saved in the same directory as their SolidWorks drawing source files.
  • The original files (.SLDDRW) will be opened, rebuilt, and closed, with no changes.

Steps to Set Up the Macro

  1. Register the Macro File: Start with SolidWorks open and go to Tools>Macro>New.
  2. Name and Register: Give the macro a meaningful name (e.g., BatchPDFExport.swp) and save the file. This step will open your VBA editor automatically.
  3. Paste the code: Download the VBA code we have provided below and place it in your editor.
  4. Define Target Folder (Important step): In the VBA editor, in the Sub Main() sub-routine, replace the file path in the code line:

RebuildAndSaveAllDrawingsAsPDF “C:\SOLIDWORKS”, “.SLDDRW”, True

Replace “C:\SOLIDWORKS” with the target folder where your drawing files are located. This SOLIDWORKS macro to batch rebuild and export drawings to PDF helps streamline this process by automating rebuild and export tasks for all drawings within the specified folder.

  1. Run Macro: Close your VBA editor and save the work when prompted. You can now run the macro with Tools>Macro>Run or an assigned shortcut.

VBA Macro Code

Macro

You can download the macro from here.

Need Customization & Expert Support?

If so, make sure to reach out! Our specialized team at Blue Byte Systems Inc. develops custom macros and add-ins to meet these advanced workflow needs.

Author

Amen Jlili

Amen Jlili is the founder and technical director of Blue Byte Systems Inc., a software company in Vancouver, Canada, specializing in automating SOLIDWORKS and PDM. With over a decade of experience, he has authored several courses and open-source frameworks related to the SOLIDWORKS API. His leadership ensures that Blue Byte Systems prioritizes customer satisfaction and delivers high-quality software and CAD design solutions.
0
    0
    Your Cart
    Your cart is emptyReturn to Shop
    ×