- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Preset all addins to Demand Load. Won't load until something needs it too. Much of Inventor startup time is not the add-in's anyway.
Can you run multiple Inventors, yes, if you start them via your code. I have a VB.Net exe that does NOT run as an Inventor Add-IN it uses this to get Inventor:
Public Function GetInventorApplication() As Inventor.Application
If invApp Is Nothing Then
If invAppCollection IsNot Nothing Then
If invAppCollection.Count > 0 Then
For i As Integer = invAppCollection.Count - 1 To 0 Step -1
If invAppCollection(i) IsNot Nothing Then
invApp = invAppCollection(i)
Exit For
Else
invAppCollection.RemoveAt(i)
End If
Next
End If
End If
Try
invApp = Marshal.GetActiveObject("Inventor.Application
Catch ex As Exception
Try
Dim invAppType As Type = GetTypeFromProgID("Inventor.Application")
invApp = CreateInstance(invAppType)
invApp.Visible = True
'counter the app
Dim counter As Integer = 0
Do While invApp.Ready = False
counter += 1
Debug.Print(counter)
If counter > 1000 Then
Exit Do
End If
Loop
For Each addIn As ApplicationAddIn In invApp.ApplicationAddIns
Try
If addIn.LoadBehavior = AddInLoadBehaviorEnum.kLoadImmediately Then
addIn.Activate()
End If
Catch exAddIn As Exception
'skip it
End Try
Next
invAppWasStarted = True
Catch ex2 As Exception
MsgBox("Unable to get or start Inventor" & vbCr & ex2.ToString, MsgBoxStyle.SystemModal)
End Try
End Try
End If
Try
Dim dcountTest As Integer = invApp.Documents.Count
Catch ex As Exception
invApp = Nothing
GetInventorApplication()
End Try
Return invApYou can use the application collection to separate which Inventor is doing what that way. Note my code did not Add the new inventor to the collection, you will need to do that.
Some random thoughts:
Unless your running a KickA machine running multiple Inventor's may not be a good idea. I would also like to add another point, if Inventor keeps crashing, your documents may need to be Migrated with Total Rebuild to update their versions to the latest versions. Inventor can, but does not like running multiple version assembly files, and tends to get stupid. Closing all documents should allow inventor time to purge its memory sponge, but I agree it still tends to leak memory (if not hemorrhage). The Task scheduler puts a clock on the inventor applications and attempts retry 3 times. It also performs a max file count before closing Inventor and starting a new one. I've experimented with this. All is well unless you get Vault involved. Finally, Inventor handles System.Threading.Tasks.Parallel.For, meaning you can get it to run multiple tasks on multiple threads at once. This is good when using tasks that look up lists, and such, not so good when adding to the database (use SyncLock or die!) So you may be able to have multiple documents process at once if you code it right.