Hi,
I have: A folder with 200 .step files of assemblies with multiple bodies.
I want: A folder with 200 .ipt files containing a single body.
How i go about this manually:
1. Import the .step file into Inventor, this results into a .iam file which i save in the same folder
2. Open a new .ipt file and use 'Derive', select the saved .iam i want and use option 'combine into one body'.
3. Break the derive link and save the .ipt file which now contains a single body
This is alot of clicking to repeat for 200 files.
Does anyone know a way to automate this?
Solved! Go to Solution.
Solved by Andrii_Humeniuk. Go to Solution.
Solved by Andrii_Humeniuk. Go to Solution.
Solved by Andrii_Humeniuk. Go to Solution.
Hi @Daan_M . Change the path to your template file (line 24).
Imports System.Windows.Forms
Sub main
oInvApp = ThisApplication
oProject = oInvApp.DesignProjectManager.ActiveDesignProject
Dim sPathFolder As String = GetPathFolder(oProject.WorkspacePath)
If String.IsNullOrEmpty(sPathFolder) Then Exit Sub
Dim sFiles() As String = System.IO.Directory.GetFiles(sPathFolder & "\", "*.STEP")
If sFiles.Length = 0 Then Exit Sub
Dim oPB As Inventor.ProgressBar
oPB = oInvApp.CreateProgressBar(False, sFiles.Length - 1, "Create parts from step files...")
oPB.Message = ("Loading...")
For i As Integer = 0 To sFiles.Length - 1
Dim oNewAsmName As String = CreateAssemblyFromSTEP(sFiles(i))
If String.IsNullOrEmpty(oNewAsmName) Then Continue For
Call CreatePartDriveAsm(oNewAsmName, sFiles(i))
oPB.Message = ("Create part from step file. Progress " & i & " of " & sFiles.Length - 1 & ".")
oPB.UpdateProgress
Next i
oPB.Close()
End Sub
Dim oInvApp As Inventor.Application
Dim sTemplate As String = "\\Comp59\Work SP\Templates\ru-RU\КТВ_Деталь.ipt"
Private Function GetPathFolder(ByVal sPathStart As String) As String
Dim Dialog = New FolderBrowserDialog()
Dialog.SelectedPath = sPathStart
If DialogResult.OK = Dialog.ShowDialog() Then
Return Dialog.SelectedPath
End If
Return Nothing
End Function
Private Function CreateAssemblyFromSTEP(ByVal sPathFile As String) As String
Dim oDoc As Document = oInvApp.Documents.Open(sPathFile, False)
oDoc.Save()
oDoc.Close(True)
Return oDoc.FullFileName
End Function
Private Function CreatePartDriveAsm(ByVal oNewAsmName As String, ByVal sPathFile As String)
Dim oDerivedAssemblyDef As DerivedAssemblyDefinition
Dim oPDoc As PartDocument = oInvApp.Documents.Add(kPartDocumentObject, sTemplate, False)
Dim oRefComps As ReferenceComponents = oPDoc.ComponentDefinition.ReferenceComponents
oDerivedAssemblyDef = oRefComps.DerivedAssemblyComponents.CreateDefinition(oNewAsmName)
oDerivedAssemblyDef.DeriveStyle = DerivedComponentStyleEnum.kDeriveAsMultipleBodies
oDerivedAssemblyDef.IncludeAllTopLevelWorkFeatures = DerivedComponentOptionEnum.kDerivedExcludeAll
oDerivedAssemblyDef.IncludeAllTopLevelSketches = DerivedComponentOptionEnum.kDerivedExcludeAll
oDerivedAssemblyDef.IncludeAllTopLeveliMateDefinitions = DerivedComponentOptionEnum.kDerivedExcludeAll
oDerivedAssemblyDef.IncludeAllTopLevelParameters = DerivedComponentOptionEnum.kDerivedExcludeAll
Dim oDerivedAss As DerivedAssemblyComponent
oDerivedAss = oRefComps.DerivedAssemblyComponents.Add(oDerivedAssemblyDef)
Call oDerivedAss.BreakLinkToFile()
oPDoc.SaveAs(System.IO.Path.ChangeExtension(sPathFile, "(Part).ipt"), False)
oPDoc.Close(True)
End Function
Andrii Humeniuk - Leading design engineer
LinkedIn | My free Inventor Addin | My Repositories
Did you find this reply helpful ? If so please use the Accept as Solution/Like.
@Andrii_Humeniuk Thank you, great code, i restructed it a bit and changed some text for my case.
Imports System.Windows.Forms
Sub Main
oInvApp = ThisApplication
oProject = oInvApp.DesignProjectManager.ActiveDesignProject
Dim sPathFolder As String = GetPathFolder(oProject.WorkspacePath)
If String.IsNullOrEmpty(sPathFolder) Then
MsgBox("geen folder geselecteerd")
Exit Sub
End If
'/// STEP ///
Dim sFiles() As String = System.IO.Directory.GetFiles(sPathFolder & "\", "*.STEP")
If sFiles.Length = 0 Then
Exit Sub
End If
Dim oPB As Inventor.ProgressBar
oPB = oInvApp.CreateProgressBar(False, sFiles.Length - 1, "Parts aanmaken uit STP files...")
oPB.Message = ("Even geduld...")
For i As Integer = 0 To sFiles.Length - 1
Dim oNewAsmName As String = CreateAssemblyFromSTEP(sFiles(i))
' If String.IsNullOrEmpty(oNewAsmName) Then Continue For
Call CreatePartDriveAsm(oNewAsmName, sFiles(i))
oPB.Message = ("Bezig met " & i & " of " & sFiles.Length - 1 & ".")
oPB.UpdateProgress
Next i
oPB.Close()
End Sub
Dim oInvApp As Inventor.Application
Dim sTemplate As String = "X:\CAD_3D\00 - Inventor standaard (NIET AANKOMEN)\Templates\Metric\Standard (mm).ipt"
Private Function GetPathFolder(ByVal sPathStart As String) As String
Try
Dim Dialog = New FolderBrowserDialog()
Dialog.SelectedPath = sPathStart
If DialogResult.OK = Dialog.ShowDialog() Then
Return Dialog.SelectedPath
End If
Return Nothing
Catch
Exit Function
End Try
End Function
Private Function CreateAssemblyFromSTEP(ByVal sPathFile As String) As String
' Try
Dim oDoc As Document = oInvApp.Documents.Open(sPathFile, False)
oDoc.Save()
If oDoc.DocumentType = kPartDocumentObject Then
Dim Svar As Integer = 1
Return Svar
End If
oDoc.Close(True)
Return oDoc.FullFileName
' Catch
' Exit Function
' End Try
End Function
Private Function CreatePartDriveAsm(ByVal oNewAsmName As String, ByVal sPathFile As String)
'Try
Dim oDerivedAssemblyDef As DerivedAssemblyDefinition
Dim oPDoc As PartDocument = oInvApp.Documents.Add(kPartDocumentObject, sTemplate, False)
Dim oRefComps As ReferenceComponents = oPDoc.ComponentDefinition.ReferenceComponents
oDerivedAssemblyDef = oRefComps.DerivedAssemblyComponents.CreateDefinition(oNewAsmName)
oDerivedAssemblyDef.DeriveStyle = DerivedComponentStyleEnum.kDeriveAsMultipleBodies
oDerivedAssemblyDef.IncludeAllTopLevelWorkFeatures = DerivedComponentOptionEnum.kDerivedExcludeAll
oDerivedAssemblyDef.IncludeAllTopLevelSketches = DerivedComponentOptionEnum.kDerivedExcludeAll
oDerivedAssemblyDef.IncludeAllTopLeveliMateDefinitions = DerivedComponentOptionEnum.kDerivedExcludeAll
oDerivedAssemblyDef.IncludeAllTopLevelParameters = DerivedComponentOptionEnum.kDerivedExcludeAll
Dim oDerivedAss As DerivedAssemblyComponent
oDerivedAss = oRefComps.DerivedAssemblyComponents.Add(oDerivedAssemblyDef)
Call oDerivedAss.BreakLinkToFile()
oPDoc.SaveAs(System.IO.Path.ChangeExtension(sPathFile, "SIMPLIFIED.ipt"), False)
oPDoc.Close(True)
' Catch
' Exit Function
' End Try
End Function
I have two additional questions;
1. some of the .STEP files are translated to a Partdocument instead of an Assembly document. This causes a problem in the function below, since it expects the file to be an assembly and not a part.
Private Function CreatePartDriveAsm
It would be ok to skip this function for the most part, and it just saved the partfile directly as is.
How can i best do this?
2. The output is a bit messy at the moment;
Green = original .STEP file in my folder
Blue = The folder Inventor creates when saving the translated .STEP file to a native assembly.
Red = The output i need
Yellow = All the parts from the assemblies after translation from .STEP
Yellow and Blue can be deleted i just need the orinals files (Green) and the output (Red) to be left in the folder
I wrote the code according to my template, but added your changes to it. In case, if an .ipt was created after converting the STEP file, it will be renamed to "SIMPLIFIED.ipt" if the ".iam" is followed by the old actions. Added DeleteDontNeedFile function to delete ".iam" folder.
Imports System
Imports System.Windows.Forms
Sub main
oInvApp = ThisApplication
oProject = oInvApp.DesignProjectManager.ActiveDesignProject
Dim sPathFolder As String = GetPathFolder(oProject.WorkspacePath)
If String.IsNullOrEmpty(sPathFolder) Then Exit Sub
Dim sFiles() As String = IO.Directory.GetFiles(sPathFolder & "\", "*.STEP")
If sFiles.Length = 0 Then Exit Sub
Dim oPB As Inventor.ProgressBar
oPB = oInvApp.CreateProgressBar(False, sFiles.Length - 1, "Parts aanmaken uit STP files...")
oPB.Message = ("Even geduld...")
For i As Integer = 0 To sFiles.Length - 1
Dim oNewAsmName As String = CreateAssemblyFromSTEP(sFiles(i))
If String.IsNullOrEmpty(oNewAsmName) Then Continue For
Call CreatePartDrive(oNewAsmName, sFiles(i))
Call DeleteDontNeedFile(oNewAsmName)
oPB.Message = ("Bezig met " & i & " of " & sFiles.Length - 1 & ".")
oPB.UpdateProgress
Next i
oPB.Close()
Shell("explorer.exe /Open," & sPathFolder, vbNormalFocus)
End Sub
Dim oInvApp As Inventor.Application
Dim sTemplate As String = "X:\CAD_3D\00 - Inventor standaard (NIET AANKOMEN)\Templates\Metric\Standard (mm).ipt"
Private Function GetPathFolder(ByVal sPathStart As String) As String
Dim Dialog = New FolderBrowserDialog()
Dialog.SelectedPath = sPathStart
If DialogResult.OK = Dialog.ShowDialog() Then
Return Dialog.SelectedPath
End If
Return Nothing
End Function
Private Function CreateAssemblyFromSTEP(ByVal sPathFile As String) As String
Dim oDoc As Document = oInvApp.Documents.Open(sPathFile, False)
oDoc.Save()
oDoc.Close(True)
Return oDoc.FullFileName
End Function
Private Function CreatePartDrive(ByVal oNewAsmName As String, ByVal sPathFile As String)
If IO.Path.GetExtension(oNewAsmName) = ".ipt" Then
IO.Path.ChangeExtension(oNewAsmName, "SIMPLIFIED.ipt")
Else If IO.Path.GetExtension(oNewAsmName) = ".iam" Then
Dim oPDoc As PartDocument = oInvApp.Documents.Add(kPartDocumentObject, sTemplate, False)
Dim oRefComps As ReferenceComponents = oPDoc.ComponentDefinition.ReferenceComponents
Dim oDerivedAssemblyDef As DerivedAssemblyDefinition
oDerivedAssemblyDef = oRefComps.DerivedAssemblyComponents.CreateDefinition(oNewAsmName)
oDerivedAssemblyDef.DeriveStyle = DerivedComponentStyleEnum.kDeriveAsMultipleBodies
oDerivedAssemblyDef.IncludeAllTopLevelWorkFeatures = DerivedComponentOptionEnum.kDerivedExcludeAll
oDerivedAssemblyDef.IncludeAllTopLevelSketches = DerivedComponentOptionEnum.kDerivedExcludeAll
oDerivedAssemblyDef.IncludeAllTopLeveliMateDefinitions = DerivedComponentOptionEnum.kDerivedExcludeAll
oDerivedAssemblyDef.IncludeAllTopLevelParameters = DerivedComponentOptionEnum.kDerivedExcludeAll
Dim oDerivedAss As DerivedAssemblyComponent
oDerivedAss = oRefComps.DerivedAssemblyComponents.Add(oDerivedAssemblyDef)
Call oDerivedAss.BreakLinkToFile()
oPDoc.SaveAs(IO.Path.ChangeExtension(sPathFile, "SIMPLIFIED.ipt"), False)
oPDoc.Close(True)
End If
End Function
Private Function DeleteDontNeedFile(ByVal oNewAsmName As String)
If IO.Path.GetExtension(oNewAsmName) = ".iam" Then
Dim sDirectory As String = IO.Path.GetDirectoryName(oNewAsmName)
Try : IO.Directory.Delete(sDirectory, True)
Catch : MessageBox.Show(sDirectory, "Failed to delete folder!") : End Try
End If
End Function
In my situation the Inventor put all the build files in one folder so all I had to do was delete the folder, if you have parts being created outside of the folder then let me know and I will make changes to the DeleteDontNeedFile function.
Andrii Humeniuk - Leading design engineer
LinkedIn | My free Inventor Addin | My Repositories
Did you find this reply helpful ? If so please use the Accept as Solution/Like.
Hi @Andrii_Humeniuk,
I made a few slight adjustments, all parts get moved to the 'Outputs folder' now (red).
Problem: if the STEP/STP file contains a part, then a subfolder is created automatically by Inventor, the result part gets put in there, instead of the original path. So this part will remain in the subfolder (blue) and not moved to the 'Outputs' folder.
Full Code
Imports System
Imports System.Windows.Forms
Sub main
oInvApp = ThisApplication
oProject = oInvApp.DesignProjectManager.ActiveDesignProject
Dim sPathFolder As String = GetPathFolder(oProject.WorkspacePath)
If String.IsNullOrEmpty(sPathFolder) Then Exit Sub
Dim oExtensions(1) As String
oExtensions(0) = "*.STP"
oExtensions(1) = "*.STEP"
For Each Extension In oExtensions
Dim sFiles() As String = IO.Directory.GetFiles(sPathFolder & "\", Extension)
If sFiles.Length = 0 Then Exit Sub
Dim oPB As Inventor.ProgressBar
oPB = oInvApp.CreateProgressBar(False, sFiles.Length - 1, "Parts aanmaken & Solids hernoemen...")
oPB.Message = ("Even geduld...")
For i As Integer = 0 To sFiles.Length - 1
Dim oNewAsmName As String = CreateAssemblyFromSTEP(sFiles(i))
If String.IsNullOrEmpty(oNewAsmName) Then Continue For
Call CreatePartDrive(oNewAsmName, sFiles(i))
Call DeleteDontNeedFile(oNewAsmName)
oPB.Message = ("Bezig met " & i + 1 & " of " & sFiles.Length & ".")
oPB.UpdateProgress
Next i
'hier worden alleen parts aangepakt
Dim iptFiles() As String = IO.Directory.GetFiles(sPathFolder & "\", "*.ipt")
For i As Integer = 0 To iptFiles.Length - 1
Dim oCleanNames As String = CleanNames(iptFiles(i))
Next i
oPB.Close()
Shell("explorer.exe /Open," & sPathFolder, vbNormalFocus)
Next
Dim OutputFolder As IO.DirectoryInfo = IO.Directory.CreateDirectory(sPathFolder & "\Outputs")
Dim AllPartFiles() As String = IO.Directory.GetFiles(sPathFolder & "\", "*.ipt")
For Each PartFile As String In AllPartFiles
Dim Destination As String = OutputFolder.FullName & "\" & IO.Path.GetFileName(PartFile)
IO.File.Move(PartFile, Destination)
Next
End Sub
Dim oInvApp As Inventor.Application
Dim sTemplate As String = "X:\CAD_3D\00 - Inventor standaard (NIET AANKOMEN)\Templates\Metric\Standard (mm).ipt"
Private Function GetPathFolder(ByVal sPathStart As String) As String
Dim Dialog = New FolderBrowserDialog()
Dialog.SelectedPath = sPathStart
If DialogResult.OK = Dialog.ShowDialog() Then
Return Dialog.SelectedPath
End If
Return Nothing
End Function
Private Function CleanNames(ByVal sPathFile As String) As String
Dim oDoc As Inventor.Document = oInvApp.Documents.Open(sPathFile, False)
Dim oPCD As PartComponentDefinition = oDoc.ComponentDefinition
Dim oFeature As PartFeature
i = 1
For Each oFeature In oPCD.Features
oFeature.Name = "BodyReset" & i
i = i + 1
Next
oDoc.Save()
oDoc.Close(True)
End Function
Private Function CreateAssemblyFromSTEP(ByVal sPathFile As String) As String
Dim oDoc As Document = oInvApp.Documents.Open(sPathFile, False)
If oDoc.DocumentType = kAssemblyDocumentObject Then
Dim i As Integer = 1
Dim oAsmCompDef As AssemblyComponentDefinition = oDoc.ComponentDefinition
Dim oOcc As ComponentOccurrence
For Each oOcc In oAsmCompDef.Occurrences
oOcc.Name = "BodyReset" & i
i = i + 1
Next
End If
oDoc.Save()
oDoc.Close(True)
Return oDoc.FullFileName
End Function
Private Function CreatePartDrive(ByVal oNewAsmName As String, ByVal sPathFile As String)
If IO.Path.GetExtension(oNewAsmName) = ".ipt" Then
IO.Path.ChangeExtension(oNewAsmName, ".ipt") 'Simplified
Else If IO.Path.GetExtension(oNewAsmName) = ".iam" Then
Dim oPDoc As PartDocument = oInvApp.Documents.Add(kPartDocumentObject, sTemplate, False)
Dim oRefComps As ReferenceComponents = oPDoc.ComponentDefinition.ReferenceComponents
Dim oDerivedAssemblyDef As DerivedAssemblyDefinition
oDerivedAssemblyDef = oRefComps.DerivedAssemblyComponents.CreateDefinition(oNewAsmName)
oDerivedAssemblyDef.DeriveStyle = DerivedComponentStyleEnum.kDeriveAsMultipleBodies
oDerivedAssemblyDef.IncludeAllTopLevelWorkFeatures = DerivedComponentOptionEnum.kDerivedExcludeAll
oDerivedAssemblyDef.IncludeAllTopLevelSketches = DerivedComponentOptionEnum.kDerivedExcludeAll
oDerivedAssemblyDef.IncludeAllTopLeveliMateDefinitions = DerivedComponentOptionEnum.kDerivedExcludeAll
oDerivedAssemblyDef.IncludeAllTopLevelParameters = DerivedComponentOptionEnum.kDerivedExcludeAll
Dim oDerivedAss As DerivedAssemblyComponent
oDerivedAss = oRefComps.DerivedAssemblyComponents.Add(oDerivedAssemblyDef)
Call oDerivedAss.BreakLinkToFile()
oPDoc.SaveAs(IO.Path.ChangeExtension(sPathFile, ".ipt"), False) ' simplified
oPDoc.Close(True)
End If
End Function
Private Function DeleteDontNeedFile(ByVal oNewAsmName As String)
If IO.Path.GetExtension(oNewAsmName) = ".iam" Then ' simplified
Dim sDirectory As String = IO.Path.GetDirectoryName(oNewAsmName)
Try : IO.Directory.Delete(sDirectory, True)
Catch : MessageBox.Show(sDirectory, "Kan folder niet verwijderen") : End Try
End If
End Function
Hi @Daan_M . Unfortunately, I was unable to reproduce your situation. In my case, Assembly files are constantly being created. But I've optimized your code anyway, and added a line of code (79-81) that I hope will help you. It checks where the .ipt file is located and moves it if necessary.
Imports System
Imports System.Windows.Forms
Sub Main
oInvApp = ThisApplication
oProject = oInvApp.DesignProjectManager.ActiveDesignProject
Dim sPathFolder As String = GetPathFolder(oProject.WorkspacePath)
If String.IsNullOrEmpty(sPathFolder) Then Exit Sub
Dim sFiles() As String = IO.Directory.GetFiles(sPathFolder & "\").Where(Function(s) {".STP", ".STEP" }.
Contains(IO.Path.GetExtension(s))).OrderBy(Function(s) IO.Path.GetFileName(s)).ToArray()
If sFiles.Length = 0 Then Exit Sub
Dim oPB As Inventor.ProgressBar
oPB = oInvApp.CreateProgressBar(False, sFiles.Length, "Parts aanmaken & Solids hernoemen...")
oPB.Message = ("Even geduld...")
oPB.UpdateProgress
For i As Integer = 0 To sFiles.Length - 1
Dim oNewAsmName As String = CreateComponentFromSTEP(sFiles(i))
If String.IsNullOrEmpty(oNewAsmName) Then Continue For
Call CreatePartDrive(oNewAsmName, sFiles(i))
Call DeleteDontNeedFile(oNewAsmName)
oPB.Message = ("Bezig met " & i + 1 & " of " & sFiles.Length & ".")
oPB.UpdateProgress
Next i
oPB.Message = "hier worden alleen parts aangepakt"
oPB.UpdateProgress
Dim OutputFolder As IO.DirectoryInfo = IO.Directory.CreateDirectory(sPathFolder & "\Outputs")
Dim AllPartFiles() As String = IO.Directory.GetFiles(sPathFolder & "\", "*.ipt")
For Each PartFile As String In AllPartFiles
Dim Destination As String = OutputFolder.FullName & "\" & IO.Path.GetFileName(PartFile)
IO.File.Move(PartFile, Destination)
Next
oPB.Close()
Shell("explorer.exe /Open," & sPathFolder, vbNormalFocus)
End Sub
Dim oInvApp As Inventor.Application
Dim sTemplate As String = "X:\CAD_3D\00 - Inventor standaard (NIET AANKOMEN)\Templates\Metric\Standard (mm).ipt"
Private Function GetPathFolder(ByVal sPathStart As String) As String
Dim Dialog = New FolderBrowserDialog()
Dialog.SelectedPath = sPathStart
If DialogResult.OK = Dialog.ShowDialog() Then
Return Dialog.SelectedPath
End If
Return Nothing
End Function
Private Function CreateComponentFromSTEP(ByVal sPathFile As String) As String
Dim oDoc As Document = oInvApp.Documents.Open(sPathFile, False)
If oDoc.DocumentType = kAssemblyDocumentObject Then
Dim oAsmCompDef As AssemblyComponentDefinition = oDoc.ComponentDefinition
For i As Integer = 1 To oAsmCompDef.Occurrences.Count
oAsmCompDef.Occurrences(i).Name = "BodyReset" & i
Next i
Else
Dim oPCD As PartComponentDefinition = oDoc.ComponentDefinition
For i As Integer = 1 To oPCD.Features.Count
oPCD.Features(i).Name = "BodyReset" & i
Next i
End If
oDoc.Save()
oDoc.Close(True)
Return oDoc.FullFileName
End Function
Private Function CreatePartDrive(ByVal oNewAsmName As String, ByVal sPathFile As String)
If IO.Path.GetExtension(oNewAsmName) = ".ipt" Then
If IO.Path.GetDirectoryName(oNewAsmName) <> sPathFile Then
IO.File.Move(oNewAsmName, sPathFile & "\" & IO.Path.GetFileName(oNewAsmName))
End If
Else If IO.Path.GetExtension(oNewAsmName) = ".iam" Then
Dim oPDoc As PartDocument = oInvApp.Documents.Add(kPartDocumentObject, sTemplate, False)
Dim oRefComps As ReferenceComponents = oPDoc.ComponentDefinition.ReferenceComponents
Dim oDerivedAssemblyDef As DerivedAssemblyDefinition
oDerivedAssemblyDef = oRefComps.DerivedAssemblyComponents.CreateDefinition(oNewAsmName)
oDerivedAssemblyDef.DeriveStyle = DerivedComponentStyleEnum.kDeriveAsMultipleBodies
oDerivedAssemblyDef.IncludeAllTopLevelWorkFeatures = DerivedComponentOptionEnum.kDerivedExcludeAll
oDerivedAssemblyDef.IncludeAllTopLevelSketches = DerivedComponentOptionEnum.kDerivedExcludeAll
oDerivedAssemblyDef.IncludeAllTopLeveliMateDefinitions = DerivedComponentOptionEnum.kDerivedExcludeAll
oDerivedAssemblyDef.IncludeAllTopLevelParameters = DerivedComponentOptionEnum.kDerivedExcludeAll
Dim oDerivedAss As DerivedAssemblyComponent
oDerivedAss = oRefComps.DerivedAssemblyComponents.Add(oDerivedAssemblyDef)
Call oDerivedAss.BreakLinkToFile()
oPDoc.SaveAs(IO.Path.ChangeExtension(sPathFile, ".ipt"), False) ' simplified
oPDoc.Close(True)
End If
End Function
Private Function DeleteDontNeedFile(ByVal oNewAsmName As String)
If IO.Path.GetExtension(oNewAsmName) = ".iam" Then ' simplified
Dim sDirectory As String = IO.Path.GetDirectoryName(oNewAsmName)
Try : IO.Directory.Delete(sDirectory, True)
Catch : MessageBox.Show(sDirectory, "Kan folder niet verwijderen") : End Try
End If
End Function
Andrii Humeniuk - Leading design engineer
LinkedIn | My free Inventor Addin | My Repositories
Did you find this reply helpful ? If so please use the Accept as Solution/Like.
Almost there, the code gives an error "on line 81 in rule: Could not find a part of the path."
which is on line:
IO.File.Move(oNewAsmName, sPathFile & "\" & IO.Path.GetFileName(oNewAsmName))
To understand better i put in a msgbox before the error giving the file location and the desired location:
MsgBox("current location: " & oNewAsmName & " desired location: " & sPathFile & "\" & IO.Path.GetFileName(oNewAsmName))
With result:
But the "ADM1.STP\" part needs to be left out.
I tried fixing it but my understanding of programming only goes so far 😅
My mistake, this should help you:
IO.File.Move(oNewAsmName, IO.Path.GetDirectoryName(sPathFile) & "\" & IO.Path.GetFileName(oNewAsmName))
Andrii Humeniuk - Leading design engineer
LinkedIn | My free Inventor Addin | My Repositories
Did you find this reply helpful ? If so please use the Accept as Solution/Like.
Can't find what you're looking for? Ask the community or share your knowledge.