09-28-2023
03:35 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
09-28-2023
03:35 AM
Got most of the code complete now, there's one problem remaining.
The copied files are empty, theres no bodies inside;
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