GetActiveDoc Activity

Purpose: This activity retrieves the currently active document from the local SolidWorks application. It returns a document ID that can be used to reference the active document in subsequent activities. If no document is currently active in SolidWorks, the activity will return an error message.

Input Properties

This activity has no input properties. It automatically retrieves the active document from SolidWorks.

Output Properties

DocumentId

Returns the document ID of the active SolidWorks document. This ID can be used to reference the document in other activities.

Type: string

Note: If an error occurs, this will contain an error message starting with "Error: " or "Unexpected error: "

Usage Example

Scenario: Get the active document from SolidWorks

Configuration:
- No configuration required (automatically gets the active document)

Result:
- DocumentId: "doc-12345" (or error message if no active document or error occurred)

Next Steps:
Use the DocumentId in subsequent activities to work with the active document.

Error Handling

Important: The activity handles errors gracefully:

  • If no document is currently active in SolidWorks, the DocumentId output will contain an error message: "Error: Unable to Get Active Document"
  • If SolidWorks is not running or no document is open, an InvalidOperationException will be caught and returned as an error message
  • If the active document cannot be retrieved, an ArgumentNullException will be caught and returned as an error message
  • Any other unexpected errors will be caught and returned with the message: "Unexpected error: {error message}"

Always check the DocumentId output to ensure it doesn't start with "Error:" before using it in subsequent activities.

Important Notes

  • SolidWorks must be installed and running on the machine running the workflow
  • At least one document must be open and active in SolidWorks for this activity to succeed
  • If a document is already tracked in the document management system, the existing document ID will be returned
  • If the active document is not yet tracked, it will be automatically added to the document management system and a new document ID will be generated
  • The DocumentId is unique for each document session and can be used in other SolidWorks activities
  • This activity is useful when you need to work with whatever document the user currently has open in SolidWorks

Related Activities