Error in Vb.net - copy of drawing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I have part of program in VB.net which I use for copy of drawing and replace part in it by another. This work correctly before some weeks, but now I have error message in picture. I do not know why. With Inventor 2019 I uninstall some old versions of Inventor.
Thank you for your help.
Here it is program:
Module KopirovatVykres
Dim _invApp As Inventor.Application
Dim _started As Boolean = False
Public Sub Kopirovat()
Try
_invApp = Marshal.GetActiveObject("Inventor.Application")
Catch ex As Exception
End Try
Dim soubor As Inventor.DrawingDocument = _invApp.ActiveDocument
If (soubor Is Nothing) Then
MsgBox("Otevři nějaký výkres!")
Else
Dim path As String = System.IO.Path.GetDirectoryName(soubor.FullFileName)
Dim path2 As String = System.IO.Path.GetFileName(soubor.FullFileName)
Dim apprentice As New Inventor.ApprenticeServerComponent()
Dim oDoc As Inventor.ApprenticeServerDocument = apprentice.Open(path & "\" & path2)
Dim myFileSaveAs As FileSaveAs = apprentice.FileSaveAs 'Save the file to a new name
Dim vykres_name As String
vykres_name = InputBox("Zadej nové číslo výkresu")
If vykres_name = "" Then
MsgBox("Nezadán žádný název výkresu!")
Else
myFileSaveAs.AddFileToSave(oDoc, path & "\" & vykres_name & ".idw") 'Uloží otevřený soubor výkresu s názvem kopie před
myFileSaveAs.ExecuteSaveCopyAs()
End If
soubor.Close()
Dim oDoc2 As Document
oDoc2 = _invApp.Documents.Open(path & "\" & vykres_name & ".idw")
oDoc2.File.ReferencedFileDescriptors(1).ReplaceReference(path & "\" & vykres_name & ".ipt")
Dim oDrawDoc As DrawingDocument = _invApp.ActiveDocument
oDrawDoc.Update()
oDrawDoc.Save()
End If
End Sub
End Module