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

Mirroring a folder of .ipt files with iLogic

I would like to mirror an entire folder containing .ipt files.

 

Not sure how to do this through iLogic, but someone pointed out using the derive mirror option might be a possibility.

I got this far but it doesn't work, if anyone can help me that would be great, left some comments in the code.

Imports System.Windows.Forms
Imports System
Sub Main
	
	oInvApp = ThisApplication
	Dim oTemplate As String = "X:\CAD_3D\00 - Inventor standaard (NIET AANKOMEN)\Templates\Standard.ipt"
	
	Dim oFBD = New FolderBrowserDialog()
	oFBD.ShowDialog()
	Dim oSFolder = oFBD.SelectedPath	
	If String.IsNullOrEmpty(oSFolder) Then Exit Sub
	
	Dim oFiles() As String = IO.Directory.GetFiles(oSFolder, "*.ipt")
	If oFiles.Length = 0 Then Exit Sub
	
	Dim i As Integer = 0 
	
		For Each oFile In oFiles
			Dim oFileName As String = IO.Path.GetFileName(i)
			Call MirDer(oFiles(i))
			i = i + 1
		Next
End Sub
	
	Dim oInvApp = ThisApplication
	
Private Function MirDer(ByVal oFileName As String)
	
	Dim CopyDoc As PartDocument = oInvApp.Documents.Add(kPartDocumentObject, oTemplate, False)
	Dim oRefComps As ReferenceComponents = CopyDoc.ComponentDefinition.ReferenceComponents
	Dim oDerivedPartDef As DerivedPartDefinition
	
	'something wrong here because i used oDerivedAssemblyDef and simply changed it to PartDef
	'The mirroring still needs to be put in the code
	'Any origin plane would be ok
	
		oDerivedPartDef = oRefComps.DerivedPartComponents.CreateDefinition(oFileName)
		oDerivedPartDef.DeriveStyle = DerivedComponentStyleEnum.kDeriveAsMultipleBodies
		oDerivedPartDef.IncludeAllTopLevelWorkFeatures = DerivedComponentOptionEnum.kDerivedExcludeAll
		oDerivedPartDef.IncludeAllTopLevelSketches = DerivedComponentOptionEnum.kDerivedExcludeAll
		oDerivedPartDef.IncludeAllTopLeveliMateDefinitions = DerivedComponentOptionEnum.kDerivedExcludeAll
		oDerivedPartDef.IncludeAllTopLevelParameters = DerivedComponentOptionEnum.kDerivedExcludeAll
		Dim oDerivedAss As DerivedPartComponent
		oDerivedAss = oRefComps.DerivedAssemblyComponents.Add(oDerivedPartDef)
	
	Call oDerivedAss.BreakLinkToFile()
	CopyDoc.SaveAs(oSFolder & "\" & oFileName & "_Bsideadjust.ipt", False)
	CopyDoc.Close(True)
	
End Function