12-04-2019
01:26 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
12-04-2019
01:26 PM
try this:
Dim oDoc As Document = ThisApplication.ActiveDocument
Dim oAsmCompDef As AssemblyComponentDefinition = oDoc.ComponentDefinition
Dim oOccPattern1 As OccurrencePattern
Dim oOccPattern2 As OccurrencePattern
Dim oObjCol As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
Dim FirstPattern As String = "Pattern One"
Dim SecondPattern As String = "Pattern Two"
'add second pattern inside first pattern
Dim occurrencePattern1 As OccurrencePattern = Nothing
Dim occurrencePattern2 As OccurrencePattern = Nothing
For Each oOccPattern In oAsmCompDef.OccurrencePatterns
If oOccPattern.Name = FirstPattern Then 'looks for the first pattern inside the assembly
occurrencePattern1 = oOccPattern
End If
If oOccPattern.Name = SecondPattern Then 'looks for the second pattern inside the assembly
occurrencePattern2 = oOccPattern
End If
Next
If (occurrencePattern1 Is Nothing Or occurrencePattern2 Is Nothing) Then
MsgBox("Paterns not found")
End If
Dim oOccurrences As ObjectCollection = occurrencePattern1.ParentComponents
oOccurrences.Add(occurrencePattern2)
occurrencePattern1.ParentComponents = oOccurrences
Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Blog: hjalte.nl - github.com