CompTree

SolidWorks Macro
Version 1.06
September 9, 2026
http://beamclc.ru/...

Generates a consolidated Bill of Materials (BOM) in Excel based on the currently open assembly.
Weldment and sheet metal parts that contain cut lists and consist of multiple bodies are treated as assemblies.
Data is populated using custom properties from the Property Manager or the cut list of a weldment or sheet metal part.
A recursive class was written to handle the tree structure; it builds and populates itself automatically.

Custom properties that should ideally be filled in within the cut lists or custom properties:
- Format
- Name
- Designation
- Mass
- Material
- Stock/Blank, Size
- Designed by, Checked by, Organization, Revision

Known limitations:
"Advanced assemblies" are not processed specially; they are treated as standard assemblies with their own sub-assemblies.
However, the macro identifies and highlights them, allowing for manual correction in the output Excel file.

Developed for SW2018; also works on later versions up to SW2024. Starting with version 1.01, operation on SW versions older than 2024 is not guaranteed.

Changelog:

Changes in v0.01a (2025/11/21):
===============================
Initial release

Changes in v0.02a (2025/11/21):
===============================
- Removed unnecessary references from the "References" block. Five dependencies should remain:
- Visual Basic For Applications
- Microsoft Forms 2.0 Type Library
- SolidWorks 2024 Type Library
- SolidWorks 2024 Constant Type Library
- SolidWorks 2024 Extensibility Type Library
If you are using an SW version other than 2024, you must uncheck the 2024-version libraries and select the corresponding ones for your specific SW version before running the macro.

Changes in v0.03 (2025/11/24):
===============================
- Bug fixes
- Cut list quantity is now derived from the number of bodies in the cut list (cntBody = swCutlistItem.GetSpecificFeature2.GetBodyCount) rather than the QUANTITY property
- Assembly depth calculation moved to a separate function (Private Function GetmaxDepth(iRootNode As clsTreeNode) As Integer)
- Excel operations moved to a separate module named "Excel"

Changes in v0.04 (2025/11/24):
===============================
- Added check for multi-body standard parts (ideally, a part should contain only one body)
- Fixed an issue where the wrong entry point could be selected when assigning the macro to a button; there is now only one entry point

Changes in v0.05 (2025/11/25):
===============================
- Bug fixes
- Cut list is updated before accessing the weldment part
- Type casting applied when calculating part or assembly mass

Changes in v0.06 2025/11/26:
===============================
- Form interface updated; form sizes made more compact.
- Three columns added: "Designed by," "Checked by," and "Organization."

Changes in v0.07 2025/12/26:
===============================
- Main and intermediate form interfaces adjusted.
- "Total Mass (kg)" column added to Excel output.
- Validation check for total mass added.
- Option added to save the BOM to Excel upon completion.

Changes in v0.08 2026/01/13:
===============================
- Property names for BOM generation can now be selected from drop-down lists (previously unused). 
- Intermediate form for viewing the component tree modified; display format made more concise. "To Notepad" and "Cancel" buttons added.

Changes in v0.09 2026/01/15:
===============================
- Promoted assemblies are highlighted in the Excel output.

Changes in v0.10 2026/04/20:
===============================
- Option added regarding components excluded from the BOM.

Changes in v0.11 2026/04/24:
===============================
- Fixed a bug in Excel BOM generation: the macro would hang when adding a comment to a cell that already contained one.
- Project password removed.

Changes in v1.01 2026/07/13:
===============================
- Fixed a bug where only the active Cut List configuration was applied for weldment parts. 
- Switched to SW2024 API.

Changes in v1.02 2026/07/15:
===============================
- Reverted to version 1.01 for SW2018 compatibility
- Fixed a bug where only the active Cut List configuration was applied for weldments

Changes in v1.03 2026/07/17:
===============================
- Minor fixes, optimization, and reduced memory leaks
- Added a progress bar

Changes in v1.04 2026/08/13:
===============================
- Fixed an error occurring when saving the Excel file: the system attempted to release resources twice, causing an error on the second attempt
- Fixed an issue with processing weldments containing cut lists and multiple configurations—specifically, cases where one configuration had a single body (treated as a part) while another had multiple bodies (treated as an assembly)

Changes in v1.05 2026/08/25:
===============================
- Added a toggle to include/exclude Envelopes
- Drop-down list values ​​are now saved in the registry
- Minor improvements

Changes in v1.06 2026/09/09:
===============================
- Translated into English