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
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 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 documentUpdate- Update custom properties in the documentValidate- Validate custom property values
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"}
Whether to include hidden properties (properties starting with underscore) in the output when extracting data.
Type: bool
Default: false
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 for the processed data: 'JSON', 'XML', or 'CSV'.
Type: string
Default: "JSON"
The valid values are:
JSON- JSON format (default)XML- XML formatCSV- CSV format
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
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
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 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.
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 in milliseconds. This indicates how long the processing operation took to complete.
Type: long
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 IDis null or empty,Successwill befalseandError Messagewill contain: "Document ID is required" - If
Processing Modeis invalid,Successwill befalseandError Messagewill contain: "Invalid processing mode: {mode}" - If an exception occurs during processing,
Successwill befalseandError Messagewill contain the error details - When errors occur,
Processed Datawill be empty,Properties Countwill be 0, andProcessing Timewill 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 Propertiesis enabled - The
Max Propertieslimit 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
- SimpleUserInputActivity - A simpler example of a configurable activity
- AddOrUpdateCustomProperty - Update a single custom property
- BulkUpdateCustomProperties - Update multiple custom properties
- ValidateCustomProperties - Validate custom property values
- OpenSolidWorksFile - Open a SolidWorks file to get a Document ID