09-28-2023
06:45 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
09-28-2023
06:45 AM
Here's my code & two test files, thank you
Imports System.Windows.Forms
Imports System
Sub Main
oInvApp = ThisApplication
Dim oTemplate As String = 'Template path
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 = kDerivedPartMirrorPlaneXY
Dim oDPC As DerivedPartComponent = oPCD.ReferenceComponents.DerivedPartComponents.Add(oDPD)
oDPC.BreakLinkToFile()
CopyDoc.Update()
CopyDoc.SaveAs(oSFolder & "\" & oFileNameWE & "_Bsideadjust.ipt", False)
CopyDoc.Close(True)
End Function