GetFileName Activity
Purpose: This activity gets the file name of a SolidWorks file using its document ID. It returns just the file name (without the full path), which is useful for display purposes or when you only need the name portion of the file.
Input Properties
Enter the document ID of the SolidWorks file to get the file name. This should be the document ID returned by activities like OpenSolidWorksFile or GetActiveDoc.
Type: string
Required: Yes
Example: "doc-12345"
Output Properties
Returns the file name of the SolidWorks file (without the path).
Type: string
Note: If an error occurs, this will contain an error message starting with "Error: " or "Unexpected error: "
Example: "Part1.SLDPRT" or "Assembly1.SLDASM"
Usage Example
Scenario: Get the file name of an opened SolidWorks document Configuration: - DocumentId: "doc-12345" Result: - FileName: "MyPart.SLDPRT" (or error message if failed) Next Steps: Use the FileName output for display purposes, logging, or to construct new file names.
Error Handling
Important: The activity handles errors gracefully:
- If the document ID is invalid or the document cannot be found, an
InvalidOperationExceptionwill be caught and returned as:"Error: {error message}" - If the document or file name is null, an
ArgumentNullExceptionwill be caught and returned as:"Error: {error message}" - Any other unexpected errors will be caught and returned as:
"Unexpected error: {error message}"
Always check the FileName output to ensure it doesn't start with "Error:" before using it in subsequent activities.
Important Notes
- The document must be open in SolidWorks and accessible via the DocumentId
- This returns only the file name (e.g., "Part1.SLDPRT"), not the full path
- Use GetFullPath activity if you need the complete file path
- The file name includes the file extension (e.g., .SLDPRT, .SLDASM, .SLDDRW)
- This is useful for display purposes, logging, or when constructing new file names
Related Activities
- GetFullPath - Get the full file path of a document
- OpenSolidWorksFile - Open a SolidWorks file to get a DocumentId
- GetActiveDoc - Get the active document ID
- CheckFileType - Check the type of a SolidWorks file