12-03-2019
02:06 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
12-03-2019
02:06 PM
Hey forum,
I have two patterns and I am trying to add one pattern inside the other but I am unsure how to do this with iLogic. I think I have to make an object collection of the pattern that needs to be patterned again ("Pattern Two").
Here's how I've approached it so far:
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 For Each oOccPattern1 In oAsmCompDef.OccurrencePatterns If oOccPattern1.Name = FirstPattern Then 'looks for the first pattern inside the assembly For Each oOccPattern2 In oAsmCompDef.OccurrencePatterns If oOccPattern2.Name = SecondPattern Then 'looks for the second pattern inside the assembly oObjCol.Add(oOccPattern2) 'adds the second pattern into a collection oOccPattern1.ParentComponents.Add(oObjCol) End If Next
E End If Next
Any help is greatly appreciated!
Thanks,
Felix
Solved! Go to Solution.
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
12-08-2019
07:24 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report