US$0.00
0

SOLIDWORKS Macro to Save Assembly as Part (Exterior Components)

Description

This macro converts an active SolidWorks assembly into a part file that contains only the exterior components. This feature is useful for reducing the complexity of the assembly when sharing with external stakeholders or for performance improvements in visualization and analysis.

SOLIDWORKS Macro to Save Assembly as Part and An image divided into two side-by-side sections labeled "Before" and "After," showing a SOLIDWORKS software interface. The "Before" section displays a 3D model of a box-like container with a hinged lid, a blue plane labeled "Top Plane," and a feature tree on the left listing "Upper & Lower_Covers" with components like "Hinge" and "Handle" under "History" and "Solid Bodies." The "After" section shows the same container with the lid closed and a shaded surface, the feature tree updated with additional "Solid Bodies" like "Upper_Cover-B1-solid1," and similar components. Both sections include toolbars and an isometric 3D view with axes indicators.

System Requirements

  • SOLIDWORKS Version: SOLIDWORKS 2014 or newer
  • Operating System: Windows 7 or later

Prerequisites

The following conditions must be satisfied for the macro to function as intended:

  • An assembly document (.SLDASM) must be currently open and the frontmost document in SOLIDWORKS.
  • The active assembly document must contain at least one part component to make the operation meaningful.

Results

  • The macro successfully takes the active assembly and saves it as a new part file (.SLDPRT) that contains only exterior geometry.
  • The part file is automatically saved in the same directory as the original assembly file using the same file name base, except with the extension .SLDPRT.
  • The original assembly document remains unchanged.

Steps to Set Up the Macro

To deploy the SOLIDWORKS macro to save assembly as part utility, you must follow these simple steps:

Prepare SolidWorks

  • Open SolidWorks and load the assembly document you wish to modify.
  • Your assembly must contain at least one part component.

Configure and Run the Macro

  • Open the SolidWorks VBA editor by pressing (Alt + F11) from within SolidWorks.
  • Add a new module, and copy the VBA macro code provided below into the module you added. The module serves as the permanent destination for the code, ensuring the utility is saved within SOLIDWORKS for repeated, quick access.
  • Next, execute the macro in SolidWorks by navigating to Tools > Macro > Run, and select the file you saved.

Outcome of Using the Macro

  • The macro will automatically save the active document as a new part file containing only the exterior parts.
  • The automation handles all the complex API settings for Save As Part simplification, ensuring that every time it is executed, in the same way, and the document preserves the history as a part file.
  • The original assembly will remain unchanged.

VBA Macro Code

Macro

You can download the macro from here.

Customization and Advanced Solutions by Experts

To get started with customizing this macro or to create any other fully custom solutions for your engineering projects, reach out to our team of engineers today!

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
    ×