Hey Briant,
I created an ilogic which could be used as framework, since you would have to add some "select" statements, amongst others, to include all the other types of mates.
Copy the code into a rule and add the rule to a form then select the source part and hit the button of the rule.
To clarify what it does, here is the internal tree I've used:
- ActiveDocument
- SelectSet
- Item(x)
- Constraints
- Item(x)
- .Type
- EntityOne
- EntityOneInferredType
- EntityTwo
- Offset
- AffectedOccurrenceOne
- Definition
- ComponentDefinition
EntityOne represents in the case of a mate constraint the face of the part you've selected. So I grabbed the InternalName of that face to search for it in the other occurences of that part. EntityTwo represents the counterpart face.
I've tested it with only one mate constraint on the source part, just to see if it would work at all.
Please test it in a safe environment.
Dim actDoc As Document
Dim IAM_Occ As ComponentOccurrences
Dim IAM_OccItem As ComponentOccurrence
Dim selected_Occs As SelectSet
Dim sourceEntityOne As Object
Dim sourceEntityOne_InternalName As String
Dim sourceEntityOne_Name As String
Dim sourceEntityOne_InferredType As InferredTypeEnum
Dim sourceEntityOne_FullFileName As String
Dim source_Offset As Double
Dim sourceEntityTwo As Object
Dim sourceEntityTwo_InferredType As InferredTypeEnum
Dim sourceConstraints As AssemblyConstraintsEnumerator
Dim IAMConstraints As AssemblyConstraints
Dim target_InternalName As String
Dim targetFaces As Faces
Dim targetFace As Face
Dim target_FullFileName As String
Dim targetFace_match As Face
actDoc = ThisApplication.ActiveDocument
actDocType = ThisApplication.ActiveDocumentType
IAMConstraints = actDoc.ComponentDefinition.Constraints
'check if the IAM has any occurences yet
If Not actDoc.ComponentDefinition.Occurrences.Count = 0 Then
IAM_Occ = actDoc.ComponentDefinition.Occurrences
selected_Occs = actDoc.SelectSet
Else
MsgBox("Assembly has no Occurences yet",,"Error")
Return
End If
If selected_Occs.Count = 1 Then
sourceConstraints = selected_Occs.Item(1).Constraints
Else
MsgBox("Select the source occurrence",,"Error")
Return
End If
source_Offset = sourceConstraints.Item(1).Offset.Value
sourceEntityOne = sourceConstraints.Item(1).EntityOne
sourceEntityOne_Name = sourceConstraints.Item(1).AffectedOccurrenceOne.Name
sourceEntityOne_InternalName = sourceConstraints.Item(1).EntityOne.InternalName
sourceEntityOne_InferredType = sourceConstraints.Item(1).EntityOneInferredType
sourceEntityOne_FullFileName = selected_Occs.Item(1).Definition.Document.FullFileName
sourceEntityTwo_InferredType = sourceConstraints.Item(1).EntityTwoInferredType
sourceEntityTwo = sourceConstraints.Item(1).EntityTwo
For Each IAM_OccItem In IAM_Occ
If Not IAM_OccItem.Name = sourceEntityOne_Name Then
If IAM_OccItem.Definition.Document.FullFileName = sourceEntityOne_FullFileName Then
targetFaces = IAM_OccItem.SurfaceBodies.Item(1).Faces
For Each targetFace In targetFaces
If targetFace.InternalName = sourceEntityOne_InternalName Then
targetFace_match = targetFace
IAMConstraints.AddMateConstraint(sourceEntityTwo, targetFace_match, source_Offset,sourceEntityOne_InferredType, sourceEntityTwo_InferredType)
End If
Next
End If
End If
Next
best regards
Matthias