Dear Autodesk - Regarding Apprentice Server 2024 migrating files with FileSaveAs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Please supply an updated Apprentice Server that can migrate files through the apprentice.FileSaveAs property. I am trying to update our VB.NET program that copies and renames files to new projects.
Right now I am having to use an active Inventor instance and if I have more than one Inventor open or if it chooses an Inventor instance that the project file is locked, it is corrupting some file references. Thankfully we have good backups!
Here is how I am doing it right now but this only works if we close all Inventors except one and make sure no files are open thus assuring the project isn't "locked".
Does anyone know how I can prevent this from happening? I would like to open a new instance and force the VB form to use that instance but I don't know how to do it.
Public Class DlgMigrateList
Private Sub DlgMigrateList_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.CenterToParent()
End Sub
Private Sub DlgMigrateList_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
Form1.resetForm()
End Sub
Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles btnCancel.Click
Me.Close()
End Sub
Private Sub btnOk_Click(sender As Object, e As EventArgs) Handles btnOk.Click
If GetInventor() IsNot Nothing Then
GetInventor.SilentOperation = True
Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
For x As Integer = 0 To listboxMigrateFiles.Items.Count - 1
Dim locDocument As Inventor.Document = GetInventor.Documents.Open(listboxMigrateFiles.Items().Item(x), False)
If locDocument IsNot Nothing Then
locDocument.Save()
locDocument.Close()
End If
Next
GetInventor.SilentOperation = False
GetInventor.Documents.CloseAll(True)
Form1.resetForm()
MsgBox("Migration Complete. Please re-select the file to copy.", MsgBoxStyle.Information, "FYI")
Me.Close()
Else
MessageBox.Show("Please start Inventor", "Message", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Form1.resetForm()
Me.Close()
Return
End If
End Sub
Public Shared Function GetInventor() As Inventor.Application
Dim locInventor As Inventor.Application = Nothing
Try
locInventor = CType(System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application"), Inventor.Application)
Catch ex As System.Runtime.CompilerServices.RuntimeWrappedException
MessageBox.Show("Please start Inventor" & vbNewLine & ex.ToString, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
locInventor = Nothing
End Try
Return locInventor
End Function
End Class
Thank You!
Chris