AddOrUpdateCustomProperty Activity
Purpose: This activity updates a single custom property in a SolidWorks document. If the property does not exist, it will be created. If it already exists, its value will be updated.
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"
The name of the custom property to update or create.
Type: string
Required: Yes
Example: "Material" or "Part Number"
The new value for the custom property.
Type: string
Required: Yes
Example: "Steel" or "PN-12345"
Output Properties
Indicates whether the property was updated successfully.
Type: bool
Note: Returns false if the DocumentId or PropertyName is null or empty, or if an error occurs during the update operation.
Usage Example
Scenario: Update the Material property of a SolidWorks part Configuration: - DocumentId: "doc-12345" - PropertyName: "Material" - PropertyValue: "Stainless Steel" Result: - Success: true (if update was successful) Next Steps: Use the Success output to verify the property was updated before proceeding with other operations.
Error Handling
Important: The activity handles errors gracefully:
- If
DocumentIdorPropertyNameis null or empty,Successwill be set tofalse - If the document is not found or cannot be accessed,
Successwill be set tofalse - Any exceptions during the update operation will be caught and
Successwill be set tofalse
Always check the Success output to ensure the property was updated successfully before using the document in subsequent activities.
Important Notes
- The document must be open in SolidWorks and accessible via the DocumentId
- If the property does not exist, it will be created with the specified value
- If the property already exists, its value will be overwritten with the new value
- Property names are case-sensitive in SolidWorks
- Use BulkUpdateCustomProperties activity to update multiple properties at once
Related Activities
- BulkUpdateCustomProperties - Update multiple custom properties at once
- ValidateCustomProperties - Validate custom property values before updating
- OpenSolidWorksFile - Open a SolidWorks file to get a DocumentId
- GetActiveDoc - Get the active document ID