ExportBomToExcel Activity

Purpose: This activity inserts a BOM (Bill of Materials) table into a SolidWorks assembly document if one doesn't already exist, then exports the BOM data to an Excel file. It uses the specified BOM template for insertion and saves the exported Excel file to the specified location.

Input Properties

DocumentId

The SolidWorks document ID obtained from a prior GetActiveDocument activity or other related activities. This identifies the assembly document to export BOM data from.

Type: string

Required: Yes

Example: "doc-12345"

TemplatePath

Full path to the BOM template (.sldbomtbt) to use for insertion if a BOM does not already exist in the document.

Type: string

Required: Yes

Example: "C:\Templates\MyBOMTemplate.sldbomtbt"

Note: The template file must exist and be a valid SolidWorks BOM template file. This is only used if no BOM table exists in the document.

SavePath

Full file path (including filename) where the exported Excel BOM should be saved. The directory will be created if it doesn't exist.

Type: string

Required: Yes

Example: "C:\Exports\Assembly_BOM.xlsx"

Note: The file extension should be .xlsx. The directory path will be created automatically if it doesn't exist.

Output Properties

Result

True if the BOM was successfully exported to Excel; otherwise false.

Type: bool

Note: This will be false if the document is not found, if BOM insertion fails, if the export fails, or if any error occurs during the process.

SavedPath

The save path where the Excel file was exported. This is only set when Result is true.

Type: string

Note: This will contain the same path as the SavePath input if the export was successful. If Result is false, this output may not be set or may be empty.

Usage Example

Scenario: Export BOM from an assembly to Excel file

Configuration:
- DocumentId: "doc-12345"
- TemplatePath: "C:\Templates\StandardBOM.sldbomtbt"
- SavePath: "C:\Exports\MyAssembly_BOM.xlsx"

Result:
- Result: true
- SavedPath: "C:\Exports\MyAssembly_BOM.xlsx"

Error Handling

Important: The activity handles errors gracefully:

  • If the document is not found (InvalidOperationException), Result will be set to false
  • If BOM insertion fails (when no BOM exists), Result will be set to false
  • If Excel export fails, Result will be set to false
  • If any other unexpected exception occurs, Result will be set to false

Always check the Result output to ensure the export was successful before using the SavedPath.

Important Notes

  • The document must be a SolidWorks assembly document (not a part or drawing)
  • The document must be open in SolidWorks or can be opened using activities and accessible via the DocumentId
  • If no BOM table exists, one will be inserted using the specified template before exporting
  • The BOM template file (.sldbomtbt) must exist and be accessible at the TemplatePath location
  • The target directory for SavePath will be created automatically if it doesn't exist
  • The exported Excel file will contain all BOM data in a structured format
  • This activity does not register or modify the document structure - it only inserts/retrieves BOM tables and exports data

Related Activities