US$0.00
0

Enforce Consistent Units: SOLIDWORKS Macro to Match Component Unit System

Description

This macro changes the unit system of all sub-parts and sub-assemblies in the active assembly to match the unit system of the main assembly. The macro ensures that all components in the assembly have a consistent unit system, which is crucial for accurate measurement and interoperability.

System Requirements

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

Pre-requisites

To execute the macro, the following prerequisites must be satisfied:

  • The active document must be an assembly document (.SLDASM) within SOLIDWORKS.
  • The macro requires the necessary file permissions to the component files (.SLDPRT, .SLDASM) in order to execute open, edit and save actions.

Results

When executed, the unit consistency is enforced with the following results: 

  • All sub-parts and sub-assemblies in the assembly will have their unit system preferences set to that of the main assembly’s unit system. 
  • The changes are permanently saved to the individual component files. 
  • A final message box will show the updated unit system (e.g., MKS, MMGS, IPS) as confirmation for the user.

Steps to Set Up the Macro

  • Registering a Macro File: Starting from open or closed SolidWorks, go to Tools > Macro > New…
  • Naming the Macro File: To help identify your macro in the near future, a good practice is to name the macro in some relevant way. For example, you may want to give the file a name like “BatchUnitMatch.swp”. Once you have entered a name for the macro, press save. A new Window for the VBA editor should pop up.
  • Place the Code: Simply download the VBA code provided below and then copy paste it into your editor.
  • Execute The Macro: Exit from the editor and save when prompted. With the active target assembly, run the macro via Tools > Macro > Run, or by your previously assigned shortcut. This SOLIDWORKS macro to match component unit system helps enforce consistent units across all parts in your assembly, ensuring accuracy and uniformity in your design data.

VBA Macro Code

You can download the macro from here.

Need Help With Customization? Get Our Expert Support!

Our specialized team at Blue Byte Systems Inc. creates custom macros and add-ins to meet any of these advanced workflow requests.

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
    ×