ExtractCustomProperties Activity
Purpose: This activity extracts all custom properties from a SolidWorks part document and returns them as a JSON string. It retrieves all property names and their values, making it easy to access and process custom property data.
Input Properties
ID of an open SolidWorks document. This should be the document ID returned by activities like OpenSolidWorksFile or GetActiveDoc.
Type: string
Required: Yes
Example: "doc-12345"
Output Properties
The extracted custom properties serialized to a JSON string. The format is a dictionary where keys are property names and values are property values.
Type: string
Note: If an error occurs, the JSON will contain an error object with "Error" and "Status" properties.
Example: {"Material": "Steel", "Part Number": "PN-12345", "Revision": "A"}
Usage Example
Scenario: Extract all custom properties from a SolidWorks part
Configuration:
- DocumentId: "doc-12345"
Result:
- Json: "{\"Material\": \"Steel\", \"Part Number\": \"PN-12345\", \"Revision\": \"A\", \"Description\": \"Main Component\"}"
Next Steps:
Parse the JSON string to access individual property values, or use it with other activities that accept JSON input.
Error Handling
Important: The activity handles errors gracefully:
- If the document ID is invalid or the document cannot be found, an
InvalidOperationExceptionwill be caught and the JSON will contain:{"Error": "{error message}", "Status": "Failed"} - If JSON serialization fails, a
JsonExceptionwill be caught and the JSON will contain:{"Error": "JSON serialization failed: {error message}", "Status": "Failed"} - Any other unexpected errors will be caught and the JSON will contain:
{"Error": "Unexpected error: {error message}", "Status": "Failed"}
Always check the JSON output for an "Error" property before using the extracted properties in subsequent activities.
Important Notes
- The document must be a SolidWorks part document (not an assembly or drawing)
- The document must be open in SolidWorks and accessible via the DocumentId
- All custom properties are extracted, including both user-defined and system properties
- The JSON output is formatted with indentation for readability
- Property names are preserved exactly as they appear in SolidWorks (case-sensitive)
- Empty or null property values will be included in the JSON output
- Use this activity to extract properties before processing or validating them
Related Activities
- ExtractPartData - Extract comprehensive part data including custom properties, volume, and more
- AddOrUpdateCustomProperty - Update a single custom property
- BulkUpdateCustomProperties - Update multiple custom properties
- ValidateCustomProperties - Validate custom property values
- OpenSolidWorksFile - Open a SolidWorks file to get a DocumentId