CaptureAssemblyStructure Activity
Purpose: This activity captures the full assembly structure including all children and sub-assemblies. It returns the complete assembly hierarchy as JSON, providing a comprehensive view of the entire assembly tree. This is useful for deep analysis, reporting, or as input for activities that need the complete assembly structure.
Input Properties
ID of the active 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
Assembly structure as JSON string containing the full hierarchy. Includes all parts, sub-assemblies, and their relationships in a nested structure.
Type: string
Note: If an error occurs, this will contain an error message starting with "Error: " or "Unexpected error: ".
Usage Example
Scenario: Capture complete assembly hierarchy for analysis Configuration: - DocumentId: "doc-12345" Result: - AssemblyStructureJson: JSON string containing complete assembly hierarchy with all parts and sub-assemblies at all levels Next Steps: Use the AssemblyStructureJson 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
InvalidOperationExceptionwill be caught andAssemblyStructureJsonwill contain:"Error: {error message}" - If the assembly structure cannot be captured,
AssemblyStructureJsonwill contain an error message - Any other unexpected errors will be caught and
AssemblyStructureJsonwill contain:"Unexpected error: {error message}"
Always check the AssemblyStructureJson 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
- This captures the complete hierarchy including all nested sub-assemblies and their children
- This activity registers and captures document IDs of all processed children (parts and sub-assemblies) throughout the entire assembly hierarchy in the document management system
- All child documents at all levels are automatically registered as COM objects, allowing them to be referenced by their document IDs in subsequent activities
- The JSON structure represents the full assembly tree with parent-child relationships
- 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
- For large assemblies, capturing the structure once and reusing it is more efficient than capturing multiple times
- This is a snapshot of the assembly at the time of capture - changes to the assembly after capture won't be reflected
Related Activities
- CaptureAssemblyParts - Capture assembly structure in GetAllPartsAsJson format
- GetAssemblyPartsAll - Get all parts in an assembly as JSON
- MatchPartInAssembly - Find a part in assembly (can use captured structure)
- MatchSubAssemblyInAssembly - Find a subassembly in assembly (can use captured structure)
- OpenSolidWorksFile - Open a SolidWorks file to get a DocumentId