MatchPartInAssembly Activity
Purpose: This activity finds a part 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 parts in an 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 parts in the assembly.
Type: string
Required: Yes
Example: {"Type":"ValueDifference","RowKey":"5","Column":"Type","File1Value":"","File2Value":"Laser","IdentifierValues":{"PART NUMBER":"second_speaker"}}
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 part. If not provided, will capture automatically. This improves performance when searching for multiple parts.
Type: string
Required: No
Note: Use the output from CaptureAssemblyStructure or CaptureAssemblyParts to provide this value for better performance.
Output Properties
Indicates whether the part was found in the assembly.
Type: bool
Note: Returns true if a matching part is found, false if not found or if an error occurs.
Document ID of the found part. This can be used to reference the part in subsequent activities.
Type: string
Note: Will be empty if the part was not found or if an error occurred.
Name of the found part. This is the file name or display name of the part.
Type: string
Note: Will be empty if the part was not found or if an error occurred.
Usage Example
Scenario: Find a part in an assembly by part number
Configuration:
- DocumentId: "doc-12345"
- IdentifierValuesJson: "{\"Type\":\"ValueDifference\",\"IdentifierValues\":{\"PART NUMBER\":\"PN-12345\"}}"
- AssemblyStructureJson: "" (optional, will capture automatically)
Result:
- Found: true
- PartDocumentId: "doc-67890"
- PartName: "Component1.SLDPRT"
Next Steps:
Use the PartDocumentId to perform operations on the found part, such as extracting properties 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 PartDocumentId or PartName 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 part 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 part's custom properties (case-sensitive)
- Provide AssemblyStructureJson when searching for multiple parts to avoid re-capturing the structure each time
- The search matches against custom properties of parts in the assembly
- If multiple parts match the identifier values, the first match is returned
- Use this activity to locate specific parts before performing operations on them
- This is particularly useful when working with BOM data or part identification workflows
Related Activities
- MatchSubAssemblyInAssembly - Find a subassembly 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