Error in Vb.net - copy of drawing

Error in Vb.net - copy of drawing

premysl.misun
Advocate Advocate
367 Views
1 Reply
Message 1 of 2

Error in Vb.net - copy of drawing

premysl.misun
Advocate
Advocate

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

0 Likes
368 Views
1 Reply
Reply (1)
Message 2 of 2

Mark.Lancaster
Consultant
Consultant

@premysl.misun

 

Please use the Inventor Customization forum for programming questions and issues.

 

https://forums.autodesk.com/t5/inventor-customization/bd-p/120

 

I will have the moderator relocate it there to better suit your needs.

Mark Lancaster


  &  Autodesk Services MarketPlace Provider


Autodesk Inventor Certified Professional & not an Autodesk Employee


Likes is much appreciated if the information I have shared is helpful to you and/or others


Did this resolve your issue? Please accept it "As a Solution" so others may benefit from it.

0 Likes