CaptureAssemblyParts Activity

Purpose: This activity captures the assembly structure and returns it as JSON in the same format as GetAllPartsAsJson. It provides a snapshot of all parts and sub-assemblies in the assembly, making it useful for analysis, reporting, or as input for other activities that need assembly structure information.

Input Properties

DocumentId

ID of an open SolidWorks assembly document. This should be the document ID returned by activities like OpenSolidWorksFile or GetActiveDoc.

Type: string

Required: Yes

Example: "doc-12345"

Output Properties

AssemblyParts

Assembly structure as JSON string in the same format as GetAllPartsAsJson. Contains information about all parts and sub-assemblies in the assembly.

Type: string

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

Usage Example

Scenario: Capture assembly structure for analysis

Configuration:
- DocumentId: "doc-12345"

Result:
- AssemblyParts: JSON string containing assembly structure with all parts and sub-assemblies

Next Steps:
Use the AssemblyParts JSON with MatchPartInAssembly or MatchSubAssemblyInAssembly to avoid re-capturing the structure multiple times.

Error Handling

Important: The activity handles errors gracefully:

  • If the document ID is invalid or the document cannot be found, an InvalidOperationException will be caught and AssemblyParts will contain: "Error: {error message}"
  • If the assembly structure cannot be captured, AssemblyParts will contain an error message
  • Any other unexpected errors will be caught and AssemblyParts will contain: "Unexpected error: {error message}"

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

Important Notes

  • The document must be a SolidWorks assembly document (not a part or drawing)
  • The document must be open in SolidWorks and accessible via the DocumentId
  • The output format is the same as GetAllPartsAsJson, making it compatible with activities that expect that format
  • This activity registers and captures document IDs of all processed children (parts and sub-assemblies) in the document management system
  • All child documents are automatically registered as COM objects, allowing them to be referenced by their document IDs in subsequent activities
  • This activity is useful for caching assembly structure to avoid re-capturing it multiple times
  • Use the captured structure with MatchPartInAssembly or MatchSubAssemblyInAssembly for better performance
  • The JSON contains information about all parts and sub-assemblies in the assembly hierarchy
  • This is a snapshot of the assembly at the time of capture - changes to the assembly after capture won't be reflected

Related Activities