Hi,
thanks for your answers.
@bradeneuropeArthur:
I can be sure that there are no unresolved Files, because i usally restore all correspondending files from a .zip file. But i will give it a try after the error next occure.
@Anonymous:
Even if the .iam has some Rules in it i think they won't run before the doc was finally opened. The opening procedure runs via an VB.net addin.
Here's the code that does the work:
Private Sub Wagen_Laden(WorkPfad As String, KonfigMainPfad As String, KonfigBasePfad As String, KonfigKonfigPfad As String, KonfigVBAProjektSavePfad As String, KonfigVBAProjektName As String, CADModell As String, DialogTitle As String)
Dim oApp As Inventor.Application = g_inventorApplication
Dim oDoc As Inventor.Document = oApp.ActiveDocument
'Wenn Zipper nicht installiert dann raus
If Not IsSevenZipInstalled(DialogTitle) Then
Exit Sub
'Else
' MsgBox("7-Zip richtig installiert", , DialogTitle)
' 'Exit Sub
End If
'Wenn Dokumente in Inventor geöffnete dann raus, ansonsten Speicher bereinigen
If oApp.Documents.VisibleDocuments.Count = 1 AndAlso oDoc.FullFileName <> CADModell Then
MsgBox("Bitte schließen Sie vor Laden des Konfigurators alle geöffneten Dateien", vbInformation, DialogTitle)
Exit Sub
ElseIf oApp.Documents.VisibleDocuments.Count > 1 Then
MsgBox("Bitte schließen Sie vor Laden des Konfigurators alle geöffneten Dateien", vbInformation, DialogTitle)
Exit Sub
ElseIf oApp.Documents.VisibleDocuments.Count = 1 AndAlso oDoc.FullFileName = CADModell Then
MsgBox("Der Konfigurator ist bereits geladen", vbInformation, DialogTitle)
Exit Sub
Else
oApp.Documents.CloseAll(True)
End If
''''' !!!! Attention overwrites in local work directory
'''''ToDo: aktivieren Aus Sicherung lesen
''''Cursor.Current = Cursors.WaitCursor
'''''Juengste Sicherung suchen, zuweisen, entpacken
'''''BasisCADModell
''''Dim SicherungCADBasisDateien As String
''''SicherungCADBasisDateien = JuengsteDatei(KonfigBasePfad, "*.7z")
''''Call SevenZipUnzip(SicherungCADBasisDateien, WorkPfad)
'''''MessageBox.Show("entpacke" & Lf & SicherungCADBasisDateien & Lf & "nach" & Lf & WorkPfad)
'''''KonfigsCADDateien
''''Dim SicherungCADKonfigDateien As String
''''SicherungCADKonfigDateien = JuengsteDatei(KonfigKonfigPfad, "*.7z")
''''Call SevenZipUnzip(SicherungCADKonfigDateien, WorkPfad)
'''''MessageBox.Show("entpacke" & Lf & SicherungCADKonfigDateien & Lf & "nach" & Lf & WorkPfad)
'''''VBAProjekt
''''Dim SicherungVBAProjekt As String
''''SicherungVBAProjekt = JuengsteDatei(KonfigVBAProjektSavePfad, "*.7z")
''''Call SevenZipUnzip(SicherungVBAProjekt, _KonfigVBAProjektPfad)
'''''MessageBox.Show("entpacke" & Lf & SicherungVBAProjekt & Lf & "nach" & Lf & _KonfigVBAProjektPfad)
''''Cursor.Current = Cursors.Default
'Load Inventor VBA-Projekt für Generierung und Speicherung der Varianten-CAD-Modelle
If Not Lade_InvVBAProj(KonfigVBAProjektName, _KonfigVBAProjektPfad, DialogTitle) Then Exit Sub
Try
oApp.Documents.Open(CADModell, True) 'automatisierte Variante erzeugt manchmal Fehler bei anschließendem Schließen einer Datei -> Absturz Inventor
Catch ex2 As Exception
MsgBox("Beim Laden der Konfigurator Baugruppe ist ein Fehler aufgetreten" & vbCr &
"Bitte wenden Sie sich an ihren Administrator" & vbCr & vbCr &
"Fehlermeldung:" & vbCr & "Konfigurator Baugruppe öffnen: " & ex2.Message)
Exit Sub
End Try
Call KonfiguratorSperren(KonfigMainPfad) 'creates textfile
'Setzt Ansichtsdarstellung auf Standard
oDoc = oApp.ActiveDocument
Call oDoc.ComponentDefinition.RepresentationsManager.DesignViewRepresentations.Item("Standard").Activate
Dim cam As Inventor.Camera = oApp.ActiveView.Camera
cam.ViewOrientationType = ViewOrientationTypeEnum.kIsoTopRightViewOrientation
cam.Apply()
' open a ribbon tab
Dim asmRibbon As Ribbon = g_inventorApplication.UserInterfaceManager.Ribbons.Item("Assembly")
asmRibbon.RibbonTabs.Item("Company_Konfig").Active = True
End Sub
Please excuse the english german mixed language in the code. I hope it's nevertheless understandable.
One of the main problems is that the error only somethimes occurs, so i can't fix it reliable.
I really hope on more ideas from you to get to the cause of the bug.
Many thanks in advance