GetSheetNames Activity

Purpose: This activity retrieves all sheet names from a SolidWorks drawing document. Drawing documents can contain multiple sheets, and this activity returns a JSON array containing the names of all sheets in the document. This is useful for iterating through sheets or verifying sheet names before operations like SetActiveSheet.

Input Properties

DocumentId

ID of an open SolidWorks drawing document. This should be the document ID returned by activities like OpenSolidWorksFile or GetActiveDoc.

Type: string

Required: Yes

Example: "doc-12345"

Output Properties

SheetNames

List of sheet names as JSON string. Contains a JSON array of sheet name strings.

Type: string

Note: Returns a JSON array string like ["Sheet1", "Sheet2", "Detail View"] if successful. If an error occurs, this will contain an error message string starting with "Error: " or "Unexpected error: ".

Example: ["Sheet1", "Sheet2", "Detail View"]

SheetCount

Number of sheets found in the drawing document.

Type: int

Note: Returns the count of sheets if successful, or 0 if an error occurs or if no sheets are found.

Usage Example

Scenario: Get all sheet names from a drawing document

Configuration:
- DocumentId: "doc-12345"

Result:
- SheetNames: "[\"Sheet1\", \"Sheet2\", \"Detail View\"]"
- SheetCount: 3

Scenario: Get sheet names from a drawing with only one sheet

Configuration:
- DocumentId: "doc-12345"

Result:
- SheetNames: "[\"Sheet1\"]"
- SheetCount: 1

Error Handling

Important: The activity handles errors gracefully:

  • If InvalidOperationException occurs (e.g., document not found or invalid document type), SheetNames will contain: "Error: {exception message}" and SheetCount will be 0
  • If any other exception occurs, SheetNames will contain: "Unexpected error: {exception message}" and SheetCount will be 0
  • The activity does not throw exceptions - errors are returned in the SheetNames output

Always check the SheetNames output to verify if the operation succeeded. If the string starts with "Error: " or "Unexpected error: ", the operation failed. Otherwise, it contains a valid JSON array of sheet names.

Important Notes

  • The document must be a drawing document and must be open in SolidWorks
  • The SheetNames output is a JSON array string that can be parsed to get individual sheet names
  • Use the SheetCount output to quickly determine how many sheets are in the document
  • The sheet names returned are case-sensitive - use them exactly as returned when calling SetActiveSheet
  • This activity is useful before calling SetActiveSheet to verify that a sheet name exists
  • The activity does not register or capture document IDs - it only retrieves sheet information
  • If the drawing has no sheets, SheetNames will be an empty JSON array [] and SheetCount will be 0

Related Activities