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
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
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.
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
InvalidOperationExceptionoccurs (e.g., document not found or invalid document type),ActiveSheetNamewill contain:"Error: {exception message}"andSheetFoundwill befalse - If any other exception occurs,
ActiveSheetNamewill contain:"Unexpected error: {exception message}"andSheetFoundwill befalse - The activity does not throw exceptions - errors are returned in the
ActiveSheetNameoutput
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,
ActiveSheetNamewill be empty andSheetFoundwill befalse
Related Activities
- SetActiveSheet - Set the active sheet in a drawing document
- GetSheetNames - Get all sheet names from a drawing document
- AddNewSheet - Add a new sheet to a drawing document
- OpenSolidWorksFile - Open a SolidWorks file to get a DocumentId