MatchSubAssemblyInAssembly Activity
Purpose: This activity finds a subassembly in the active assembly by identifier values. It expects a JSON object with an 'IdentifierValues' property containing the identifier columns and values to match. This is useful for locating specific sub-assemblies in a larger assembly based on custom properties or other identifying information.
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"
JSON string containing the full difference object with 'IdentifierValues' property. The IdentifierValues should contain the property names and values to match against sub-assemblies in the assembly.
Type: string
Required: Yes
Example: {"Type":"ValueDifference","RowKey":"5","Column":"Type","File1Value":"","File2Value":"Assembly","IdentifierValues":{"PART NUMBER":"ASM-001"}}
Note: The JSON must contain an "IdentifierValues" property with a dictionary of identifier columns and their values.
Optional: Pre-captured assembly structure JSON to avoid re-capturing for each assembly. If not provided, will capture automatically. This improves performance when searching for multiple sub-assemblies.
Type: string
Required: No
Note: Use the output from CaptureAssemblyStructure or CaptureAssemblyParts to provide this value for better performance.
Output Properties
Indicates whether the subassembly was found in the assembly.
Type: bool
Note: Returns true if a matching subassembly is found, false if not found or if an error occurs.
Document ID of the found subassembly. This can be used to reference the subassembly in subsequent activities.
Type: string
Note: Will be empty if the subassembly was not found or if an error occurred.
Name of the found subassembly. This is the file name or display name of the subassembly.
Type: string
Note: Will be empty if the subassembly was not found or if an error occurred.
Usage Example
Scenario: Find a subassembly in an assembly by part number
Configuration:
- DocumentId: "doc-12345"
- IdentifierValuesJson: "{\"Type\":\"ValueDifference\",\"IdentifierValues\":{\"PART NUMBER\":\"ASM-001\"}}"
- AssemblyStructureJson: "" (optional, will capture automatically)
Result:
- Found: true
- AssemblyDocumentId: "doc-67890"
- AssemblyName: "SubAssembly1.SLDASM"
Next Steps:
Use the AssemblyDocumentId to perform operations on the found subassembly, such as extracting its structure or modifying it.
Error Handling
Important: The activity handles errors gracefully:
- If
DocumentIdorIdentifierValuesJsonis null or empty, all outputs will be set to false/empty values - If the JSON doesn't contain an "IdentifierValues" property, all outputs will be set to false/empty values
- If the IdentifierValues dictionary is empty, all outputs will be set to false/empty values
- If an exception occurs during the search, all outputs will be set to false/empty values
Always check the Found output before using AssemblyDocumentId or AssemblyName 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 retrieves the document ID of the found subassembly from the assembly structure - it does not register new documents
- The DocumentId returned is from the assembly structure that was either provided or captured during the search
- If
AssemblyStructureJsonis not provided, the activity will automatically capture the structure (which registers documents), but the registration happens in the capture process, not in this activity - The IdentifierValues must match exactly with the subassembly's custom properties (case-sensitive)
- Provide AssemblyStructureJson when searching for multiple sub-assemblies to avoid re-capturing the structure each time
- The search matches against custom properties of sub-assemblies in the assembly
- If multiple sub-assemblies match the identifier values, the first match is returned
- Use this activity to locate specific sub-assemblies before performing operations on them
- This is particularly useful when working with hierarchical assembly structures or BOM data
Related Activities
- MatchPartInAssembly - Find a part in the assembly
- CaptureAssemblyStructure - Capture assembly structure for reuse
- CaptureAssemblyParts - Capture assembly parts for reuse
- GetAssemblyPartsAll - Get all parts in an assembly
- OpenSolidWorksFile - Open a SolidWorks file to get a DocumentId