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

DocumentId

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"

PropertyName

The name of the custom property to update or create.

Type: string

Required: Yes

Example: "Material" or "Part Number"

PropertyValue

The new value for the custom property.

Type: string

Required: Yes

Example: "Steel" or "PN-12345"

Output Properties

Success

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 DocumentId or PropertyName is null or empty, Success will be set to false
  • If the document is not found or cannot be accessed, Success will be set to false
  • Any exceptions during the update operation will be caught and Success will be set to false

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