AddNewSheet Activity
Purpose: This activity adds a new sheet to a SolidWorks drawing document. Drawing documents can contain multiple sheets, and this activity allows you to create additional sheets with custom names and dimensions. The new sheet can be used for additional views, details, or layouts.
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"
Index number for the new sheet (e.g., 1, 2, 3). This determines the position of the sheet in the drawing document.
Type: int
Required: Yes
Example: 2 to add a second sheet, or 3 to add a third sheet
Optional custom name for the sheet. If empty, uses 'Sheet{SheetIndex}' as the default name.
Type: string
Required: No
Example: "Detail View" or "Assembly View" or leave empty for default name
Note: If not specified, the sheet will be named "Sheet1", "Sheet2", etc., based on the SheetIndex.
Width of the sheet in drawing units. If 0, uses default A4 width (11.0).
Type: double
Default: 11.0
Example: 11.0 for A4 width, or 17.0 for larger sheets
Note: Set to 0 to use the default A4 width (11.0 inches).
Height of the sheet in drawing units. If 0, uses default A4 height (8.5).
Type: double
Default: 8.5
Example: 8.5 for A4 height, or 11.0 for larger sheets
Note: Set to 0 to use the default A4 height (8.5 inches).
Output Properties
True if the sheet was successfully added, false otherwise.
Type: bool
Note: Returns false if the sheet addition fails, if the document is invalid, or if an error occurs.
Name of the created sheet. This will be the custom name if provided, or the default name (Sheet{SheetIndex}) if not specified.
Type: string
Note: Contains the actual name of the created sheet if Success is true, or an empty string if the operation failed.
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: "Failed to add new sheet to drawing", "Error: {exception message}", or "Unexpected error: {exception message}".
Usage Example
Scenario: Add a new sheet with default settings Configuration: - DocumentId: "doc-12345" - SheetIndex: 2 - SheetName: "" (empty, will use default) - SheetWidth: 0 (will use default 11.0) - SheetHeight: 0 (will use default 8.5) Result: - Success: true - CreatedSheetName: "Sheet2" - ErrorMessage: "" (empty string) Scenario: Add a new sheet with custom name and dimensions Configuration: - DocumentId: "doc-12345" - SheetIndex: 3 - SheetName: "Detail View" - SheetWidth: 17.0 - SheetHeight: 11.0 Result: - Success: true - CreatedSheetName: "Detail View" - ErrorMessage: "" (empty string)
Error Handling
Important: The activity handles errors gracefully:
- If the sheet addition fails,
Successwill befalse,CreatedSheetNamewill be empty, andErrorMessagewill contain: "Failed to add new sheet to drawing" - If
InvalidOperationExceptionoccurs (e.g., document not found or invalid document type),Successwill befalse,CreatedSheetNamewill be empty, andErrorMessagewill contain: "Error: {exception message}" - If any other exception occurs,
Successwill befalse,CreatedSheetNamewill be empty, andErrorMessagewill contain: "Unexpected error: {exception message}"
Always check the Success output and review the ErrorMessage if the operation fails. The CreatedSheetName will contain the actual name of the created sheet if successful.
Important Notes
- The document must be a drawing document and must be open in SolidWorks
- This activity modifies the document by adding a new sheet
- The SheetIndex determines the position of the sheet in the drawing
- If SheetName is not provided, the sheet will be named "Sheet1", "Sheet2", etc., based on the SheetIndex
- If SheetWidth or SheetHeight is 0, default A4 dimensions (11.0 x 8.5) will be used
- The new sheet becomes the active sheet after creation
- Consider saving the document after adding sheets to preserve the changes
- Use SetActiveSheet to switch to the newly created sheet if needed
Related Activities
- SetActiveSheet - Set the active sheet in a drawing document
- GetSheetNames - Get all sheet names from a drawing document
- GetActiveSheetName - Get the name of the currently active sheet
- Save - Save the document after adding sheets