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
in reply to: Daan_M

Got most of the code complete now, there's one problem remaining.

The copied files are empty, theres no bodies inside;

Daan_M_0-1695897274696.png

 

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(oFiles(i))
			Dim oFileNameWE As String = IO.Path.GetFileNameWithoutExtension(oFiles(i))
			Call MirDer(oFiles(i), oFileNameWE, oSFolder)
			i = i + 1
		Next
End Sub
	
	Dim oInvApp = ThisApplication
	
Private Function MirDer(ByVal oFileName As String, ByVal oFileNameWE As String, ByVal oSFolder As String)
	
	Dim CopyDoc As PartDocument = oInvApp.Documents.Add(kPartDocumentObject, oTemplate, False)
	Dim oPCD As Inventor.PartComponentDefinition = CopyDoc.ComponentDefinition
	Dim oDPD As Inventor.DerivedPartDefinition = oPCD.ReferenceComponents.DerivedPartComponents.CreateUniformScaleDef(oFileName)
	
	oDPD.MirrorPlane = kDerivedPartMirrorPlaneYZ
	Dim oDPC As DerivedPartComponent = oPCD.ReferenceComponents.DerivedPartComponents.Add(oDPD)

	Call oDPC.BreakLinkToFile()
	
	CopyDoc.SaveAs(oSFolder & "\" & oFileNameWE & "_Bsideadjust.ipt", False) 
	
	CopyDoc.Close(True)
	
End Function