GetActiveSheetName Activity

Purpose: This activity retrieves the name of the currently active sheet in a SolidWorks drawing document. The active sheet is the one that is currently displayed and will be used for operations like adding views, annotations, or exporting. This activity is useful for verifying which sheet is active or for logging purposes.

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

ActiveSheetName

Name of the active sheet, or empty string if not found. If an error occurs, this will contain an error message string.

Type: string

Note: Returns the sheet name if successful, an empty string if no active sheet is found, or an error message (starting with "Error: " or "Unexpected error: ") if an error occurs.

SheetFound

True if an active sheet was found, false otherwise.

Type: bool

Note: Returns true if an active sheet was found and ActiveSheetName contains a valid sheet name. Returns false if no active sheet is found or if an error occurs.

Usage Example

Scenario: Get the name of the currently active sheet

Configuration:
- DocumentId: "doc-12345"

Result:
- ActiveSheetName: "Sheet1"
- SheetFound: true

Scenario: Get active sheet name when no sheet is active

Configuration:
- DocumentId: "doc-12345"

Result:
- ActiveSheetName: "" (empty string)
- SheetFound: false

Error Handling

Important: The activity handles errors gracefully:

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

Always check the SheetFound output to verify if an active sheet was found. If SheetFound is false, check if ActiveSheetName contains an error message or is empty (indicating no active sheet).

Important Notes

  • The document must be a drawing document and must be open in SolidWorks
  • The ActiveSheetName is the name of the sheet that is currently displayed and active
  • Use the SheetFound output to quickly determine if an active sheet exists
  • The sheet name returned is case-sensitive and can be used with SetActiveSheet to reactivate the same sheet
  • This activity is useful for verifying which sheet is active before performing operations
  • The activity does not register or capture document IDs - it only retrieves the active sheet name
  • If the drawing has no sheets or no sheet is active, ActiveSheetName will be empty and SheetFound will be false

Related Activities