SetActiveSheet Activity

Purpose: This activity sets the active sheet in a SolidWorks drawing document. Drawing documents can contain multiple sheets, and this activity allows you to switch between them by specifying the sheet name. The active sheet is the one that will be used for operations like adding views, annotations, or exporting.

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"

SheetName

Name of the sheet to activate. This must match the exact name of an existing sheet in the drawing document.

Type: string

Required: Yes

Example: "Sheet1" or "Detail View"

Note: The sheet name is case-sensitive and must match exactly. Use GetSheetNames to get a list of available sheet names.

Output Properties

Success

True if the sheet was successfully activated, false otherwise.

Type: bool

Note: Returns false if the sheet name is empty, if the sheet is not found, if the document is invalid, or if an error occurs.

ErrorMessage

Error message if the operation failed. Empty string if the operation succeeded.

Type: string

Note: Contains an error message if Success is false. Error messages may include: "Sheet name cannot be empty", "Failed to activate sheet '{sheetName}'", "Error: {exception message}", or "Unexpected error: {exception message}".

Usage Example

Scenario: Activate a specific sheet in a drawing document

Configuration:
- DocumentId: "doc-12345"
- SheetName: "Sheet1"

Result:
- Success: true
- ErrorMessage: "" (empty string)

Scenario: Activate a sheet that doesn't exist

Configuration:
- DocumentId: "doc-12345"
- SheetName: "NonExistentSheet"

Result:
- Success: false
- ErrorMessage: "Failed to activate sheet 'NonExistentSheet'"

Error Handling

Important: The activity handles errors gracefully:

  • If SheetName is null or empty, Success will be false and ErrorMessage will contain: "Sheet name cannot be empty"
  • If the sheet is not found or cannot be activated, Success will be false and ErrorMessage will contain: "Failed to activate sheet '{sheetName}'"
  • If InvalidOperationException occurs (e.g., document not found or invalid document type), Success will be false and ErrorMessage will contain: "Error: {exception message}"
  • If any other exception occurs, Success will be false and ErrorMessage will contain: "Unexpected error: {exception message}"

Always check the Success output and review the ErrorMessage if the operation fails. Use GetSheetNames to get a list of available sheet names before activating a sheet.

Important Notes

  • The document must be a drawing document and must be open in SolidWorks
  • The SheetName must match exactly (case-sensitive) - use GetSheetNames to get the exact names
  • Only one sheet can be active at a time - activating a new sheet deactivates the previous one
  • The active sheet is used for operations like adding views, annotations, or exporting
  • Use this activity before performing operations that require a specific sheet to be active
  • The activity does not register or capture document IDs - it only modifies the active sheet

Related Activities