UserConfigurablePartProcessor Activity

Purpose: This is a configurable activity that allows users to specify custom processing parameters through the UI. It demonstrates how to create activities that accept user inputs for configuration. The activity can extract data, update properties, or validate data from SolidWorks documents based on user-selected processing modes and options.

Input Properties

Document ID

ID of the SolidWorks document to process. This should be the document ID returned by activities like OpenSolidWorksFile or GetActiveDoc.

Type: string

Required: Yes

Example: "doc-12345"

Processing Mode

Processing mode determines what operation to perform: 'Extract' to extract data, 'Update' to update properties, 'Validate' to validate data.

Type: string

Default: "Extract"

The valid values are:

  • Extract - Extract custom properties from the document
  • Update - Update custom properties in the document
  • Validate - Validate custom property values
Custom Properties (JSON)

Custom properties to process in JSON format. Format: {"Property1": "Value1", "Property2": "Value2"}. Used for Update and Validate modes.

Type: string

Default: "{}"

Example: {"Material": "Steel", "Part Number": "PN-12345"}

Include Hidden Properties

Whether to include hidden properties (properties starting with underscore) in the output when extracting data.

Type: bool

Default: false

Max Properties

Maximum number of properties to process. Set to 0 for no limit. When extracting, this limits how many properties are returned.

Type: int

Default: 0

Example: 10 to limit to 10 properties, or 0 for all properties

Output Format

Output format for the processed data: 'JSON', 'XML', or 'CSV'.

Type: string

Default: "JSON"

The valid values are:

  • JSON - JSON format (default)
  • XML - XML format
  • CSV - CSV format
Save to File

Whether to save results to a file. If enabled, the processed data will be written to the specified output file path.

Type: bool

Default: false

Output File Path

File path where to save results. Only used if "Save to File" is enabled.

Type: string

Required: No (only if Save to File is true)

Example: C:\Output\results.json or D:\Data\export.csv

Output Properties

Success

Indicates whether processing was successful.

Type: bool

Note: Returns false if the Document ID is invalid, if processing mode is invalid, or if an error occurs.

Processed Data

Processed data in the specified format (JSON, XML, or CSV). Contains the extracted, updated, or validated data based on the processing mode.

Type: string

Note: If processing fails, this will be an empty string.

Properties Count

Number of properties processed. This indicates how many properties were extracted, updated, or validated.

Type: int

Note: Will be 0 if processing failed or no properties were found.

Processing Time (ms)

Processing time in milliseconds. This indicates how long the processing operation took to complete.

Type: long

Error Message

Error message if processing failed. Empty string if no error occurred.

Type: string

Note: Contains a descriptive error message if Success is false.

Usage Example

Scenario: Extract custom properties from a SolidWorks part

Configuration:
- Document ID: "doc-12345"
- Processing Mode: "Extract"
- Include Hidden Properties: false
- Max Properties: 0
- Output Format: "JSON"
- Save to File: false

Result:
- Success: true
- Processed Data: "{\"Material\": \"Steel\", \"Part Number\": \"PN-12345\"}"
- Properties Count: 2
- Processing Time (ms): 15
- Error Message: ""

Scenario: Update custom properties

Configuration:
- Document ID: "doc-12345"
- Processing Mode: "Update"
- Custom Properties (JSON): "{\"Material\": \"Stainless Steel\", \"Revision\": \"B\"}"
- Output Format: "JSON"
- Save to File: true
- Output File Path: "C:\Output\update_result.json"

Result:
- Success: true
- Processed Data: "{\"Material\": \"Stainless Steel\", \"Revision\": \"B\"}"
- Properties Count: 2
- Processing Time (ms): 20
- Error Message: ""

Error Handling

Important: The activity handles errors gracefully:

  • If Document ID is null or empty, Success will be false and Error Message will contain: "Document ID is required"
  • If Processing Mode is invalid, Success will be false and Error Message will contain: "Invalid processing mode: {mode}"
  • If an exception occurs during processing, Success will be false and Error Message will contain the error details
  • When errors occur, Processed Data will be empty, Properties Count will be 0, and Processing Time will still reflect the time taken

Always check the Success output and review the Error Message if processing fails.

Important Notes

  • The document must be open in SolidWorks and accessible via the Document ID
  • This activity demonstrates advanced configuration patterns for user-configurable activities
  • Different processing modes perform different operations - choose the appropriate mode for your needs
  • When extracting, hidden properties (starting with underscore) are excluded by default unless Include Hidden Properties is enabled
  • The Max Properties limit applies only to extraction mode
  • Output format affects how the data is structured - JSON is most common, CSV is useful for spreadsheet import
  • If "Save to File" is enabled, ensure the output file path is valid and writable
  • This activity serves as a reference implementation for creating similar complex configurable activities

Related Activities