Dear Autodesk - Regarding Apprentice Server 2024 migrating files with FileSaveAs

Dear Autodesk - Regarding Apprentice Server 2024 migrating files with FileSaveAs

chrisw01a
Collaborator Collaborator
306 Views
4 Replies
Message 1 of 5

Dear Autodesk - Regarding Apprentice Server 2024 migrating files with FileSaveAs

chrisw01a
Collaborator
Collaborator

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

0 Likes
307 Views
4 Replies
Replies (4)
Message 2 of 5

bradeneuropeArthur
Mentor
Mentor

You can better use Autodesk Tasksheduler for migration.

You can plan this after workinghours...

bradeneuropeArthur_0-1703709512274.png

 

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 5

chrisw01a
Collaborator
Collaborator
I have not explained enough detail.

We copy old projects all the time into new folders to modify for current jobs. We have thousands of these that we will not be migrating. But the big one is this: We have used task scheduler in the past on our "standard" design directory and it has messed up references and caused us a huge problem where we had to delete our standard products and start from scratch so we no longer use task scheduler to migrate our standard directory.

Much better for us to do it one at a time as needed.

Thoughts?

Thank you.
Message 4 of 5

bradeneuropeArthur
Mentor
Mentor
Are you using Vault?

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 5 of 5

chrisw01a
Collaborator
Collaborator
No
0 Likes