GetAssemblyPartsAll Activity
Purpose: This activity returns all parts contained in an open assembly as a JSON array of PartData objects. It can optionally de-duplicate parts by file path, which is useful when the same part appears multiple times in the assembly. This provides comprehensive information about all parts in the assembly.
Input Properties
The assembly document ID returned by GetActiveDocument or OpenSolidWorksFile. This identifies the SolidWorks assembly document to analyze.
Type: string
Required: Yes
Example: "doc-12345"
If true, de-duplicate parts by FilePath so each unique part file appears only once in the results, even if it's used multiple times in the assembly. If false, all instances of parts are included.
Type: bool
Default: true
Note: When true, if the same part appears 5 times in the assembly, it will only appear once in the results. When false, all 5 instances will be included.
Output Properties
JSON array of PartData objects. Each PartData object contains comprehensive information about a part, including custom properties, volume, material, and other metadata.
Type: string
Note: If an error occurs, the JSON will contain an error object with "Error" and "Status" properties.
Example: [{"FileName": "Part1.SLDPRT", "Volume": "1250.5 mm^3", ...}, {"FileName": "Part2.SLDPRT", ...}]
Usage Example
Scenario: Get all unique parts in an assembly Configuration: - DocumentId: "doc-12345" - DistinctByFilePath: true Result: - Json: JSON array containing PartData for each unique part file in the assembly Scenario: Get all part instances (including duplicates) Configuration: - DocumentId: "doc-12345" - DistinctByFilePath: false Result: - Json: JSON array containing PartData for every part instance in the assembly, including multiple instances of the same part
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 the JSON will contain:{"Error": "{error message}", "Status": "Failed"} - Any other unexpected errors will be caught and the JSON will contain:
{"Error": "Unexpected error: {error message}", "Status": "Failed"}
Always check the JSON output for an "Error" property before using the part data 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 activity registers and captures document IDs of all processed parts in the document management system
- All part documents are automatically registered as COM objects, allowing them to be referenced by their document IDs in subsequent activities
- When
DistinctByFilePathistrue, each unique part file appears only once, even if used multiple times - When
DistinctByFilePathisfalse, all instances of parts are included, showing the complete assembly structure - Each PartData object contains comprehensive information including custom properties, volume, material, and metadata
- This activity is useful for bill of materials (BOM) generation, part analysis, or inventory management
- The JSON array format makes it easy to iterate through all parts programmatically
- Use this activity to get a complete list of all parts before processing them individually
Related Activities
- CaptureAssemblyParts - Capture assembly structure in the same format
- CaptureAssemblyStructure - Capture full assembly hierarchy
- MatchPartInAssembly - Find a specific part in the assembly
- OpenSolidWorksFile - Open a SolidWorks file to get a DocumentId