Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

iLogic To Add Pattern Into Another Pattern In Assembly

felix.cortes5K3Y2
Advocate

iLogic To Add Pattern Into Another Pattern In Assembly

felix.cortes5K3Y2
Advocate
Advocate

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

 

 

0 Likes
Reply
Accepted solutions (1)
414 Views
2 Replies
Replies (2)

JelteDeJong
Mentor
Mentor
Accepted solution

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.

EESignature


Blog: hjalte.nl - github.com

0 Likes

felix.cortes5K3Y2
Advocate
Advocate

Thank you Jelte

0 Likes