Apprentice SaveCopyAs seems to be not working

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello guys,
i am trying to use apprentice to copy parts and assemblies belonging to a given source path to a destination path.
I managed to do this using Inventor code,
but Inventor seems to not replace the references.
So trying to put together an apprentice code to copy files.
But it always returns an exception error at following command.
oAppFileSaveAs.ExecuteSaveCopyAs()
Can anyone please look at the code and suggest me possible changes.
Thank you 🙂
Dim oApprentice As Inventor.ApprenticeServerComponent
oApprentice = New Inventor.ApprenticeServerComponent()
Dim oActiveAssembly As Inventor.ApprenticeServerDocument
oActiveAssembly = oApprentice.Open(oInv.ActiveEditDocument.FullFileName)
Dim OldFileNameList As New List(Of String)
Dim oDoc As Inventor.ApprenticeServerDocument
Dim oAppFileSaveAs As Inventor.FileSaveAs
oAppFileSaveAs = oApprentice.FileSaveAs
For Each oDoc In oActiveAssembly.AllReferencedDocuments
Dim oTempName As String
oTempName = oDoc.FullDocumentName
If oDoc.NeedsMigrating Then
MsgBox("One or more Documents in the Assembly need migrating", , "Error")
Exit For
Else
If oTempName.Contains(SourceLbl.Text) Then
Dim oOpenDoc As Inventor.ApprenticeServerDocument
oOpenDoc = oApprentice.Open(oTempName)
OldFileNameList.Add(oTempName)
Dim oNewName As String
oNewName = oTempName.Replace(SourceLbl.Text, DestinationLbl.Text)
If System.IO.File.Exists(oNewName) Then
If CheckBoxOverWrite.CheckState = 0 Then
oCopyReport.WriteLine(oNewName)
Else
oAppFileSaveAs.AddFileToSave(oOpenDoc, oNewName)
End If
Else
oAppFileSaveAs.AddFileToSave(oOpenDoc, oNewName)
End If
End If
End If
Next
oAppFileSaveAs.ExecuteSaveCopyAs()
For Each oDoc In oActiveAssembly.AllReferencedDocuments
oDoc.Close()
Next
oActiveAssembly.Close()