GetAndSaveThumbnail Activity

Purpose: This activity gets a thumbnail image of a SolidWorks document and saves it to a specified location. The thumbnail provides a visual preview of the part, which is useful for documentation, reports, or user interfaces.

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"

RootPath

Root path where the thumbnail should be saved. This is the directory where the thumbnail file will be created.

Type: string

Required: Yes

Example: C:\Thumbnails or D:\Images\Previews

Output Properties

ThumbnailPath

Path to the saved thumbnail file. This is the full file path where the thumbnail was saved.

Type: string

Note: If an error occurs, this will contain an error message starting with "Error: " or "Unexpected error: ".

Example: C:\Thumbnails\Part1_thumbnail.png

Usage Example

Scenario: Generate and save a thumbnail for a part document

Configuration:
- DocumentId: "doc-12345"
- RootPath: "C:\Thumbnails"

Result:
- ThumbnailPath: "C:\Thumbnails\Part1_thumbnail.png" (or error message if failed)

Next Steps:
Use the ThumbnailPath to display the image in reports, web interfaces, or documentation.

Error Handling

Important: The activity handles errors gracefully:

  • If the document ID is invalid or the document cannot be found, an InvalidOperationException will be caught and ThumbnailPath will contain: "Error: {error message}"
  • If the root path is invalid or inaccessible, ThumbnailPath will contain an error message
  • If the thumbnail cannot be generated, ThumbnailPath will contain an error message
  • Any other unexpected errors will be caught and ThumbnailPath will contain: "Unexpected error: {error message}"

Always check the ThumbnailPath output to ensure it doesn't start with "Error:" before using it to access the thumbnail file.

Important Notes

  • The document must be open in SolidWorks and accessible via the DocumentId
  • The root path must exist and be accessible with write permissions
  • The thumbnail file name is typically generated automatically based on the document name
  • Thumbnail format is usually PNG or JPEG, depending on SolidWorks settings
  • The thumbnail shows the part in its current view orientation
  • If the document has not been saved, the thumbnail may use a default or generated name
  • Use this activity to generate visual previews for documentation or user interfaces

Related Activities