ExtractBomData Activity

Purpose: This activity extracts structured data from a BOM (Bill of Materials) table in a SolidWorks assembly document. It retrieves the BOM table data and returns it as a JSON string containing structured information such as item numbers, part numbers, descriptions, quantities, materials, and custom properties.

Input Properties

DocumentId

ID of an open SolidWorks document. This should be a document ID obtained from a prior activity such as GetActiveDoc or OpenSolidWorksFile.

Type: string

Default: "" (empty string)

Example: "doc-12345"

Output Properties

BomDataJson

The extracted BOM data as a JSON string. Contains structured data including ItemNumber, PartNumber, Description, Quantity, Material, and CustomProperties dictionaries.

Type: string

Note: If an error occurs or no BOM table exists, this will contain an empty JSON object "{}".

Example: {"ItemNumber": {...}, "PartNumber": {...}, "Description": {...}, "Quantity": {...}, "Material": {...}, "CustomProperties": {...}}

Success

True if the BOM data was extracted successfully; otherwise false.

Type: bool

Note: This will be false if the DocumentId is empty, if no BOM table exists in the document, or if an error occurs during extraction.

Usage Example

Scenario: Extract BOM data from an assembly document

Configuration:
- DocumentId: "doc-12345"

Result:
- BomDataJson: {"ItemNumber": {"1": "1", "2": "2"}, "PartNumber": {"1": "PN-001", "2": "PN-002"}, "Description": {...}, "Quantity": {...}, "Material": {...}, "CustomProperties": {...}}
- Success: true

Error Handling

Important: The activity handles errors gracefully:

  • If DocumentId is null or empty, BomDataJson will be set to "{}" and Success will be false
  • If no BOM table exists in the document, BomDataJson will be set to "{}" and Success will be false
  • If any exception occurs during extraction, BomDataJson will be set to "{}" and Success will be false

Always check the Success output to ensure the extraction was successful before using the BomDataJson data.

Important Notes

  • The document must be a SolidWorks assembly document (not a part or drawing)
  • The document must be open in SolidWorks and accessible via the DocumentId
  • A BOM table must exist in the document before extraction can succeed
  • If no BOM table exists, use InsertBomTable activity first to create one
  • The extracted data structure includes dictionaries for ItemNumber, PartNumber, Description, Quantity, Material, and CustomProperties
  • The JSON output is formatted with indentation for readability
  • This activity does not register or modify documents - it only retrieves data from existing BOM tables

Related Activities