Error in Vb.net - copy of drawing

Error in Vb.net - copy of drawing

premysl.misun
Advocate Advocate
1,715 Views
16 Replies
Message 1 of 17

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
1,716 Views
16 Replies
Replies (16)
Message 2 of 17

bradeneuropeArthur
Mentor
Mentor

--

edit

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 17

bradeneuropeArthur
Mentor
Mentor

use this 

Dim apprentice As New Inventor.ApprenticeServerComponent

 

and not this:

 

Dim apprentice As New Inventor.ApprenticeServerComponent()

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 4 of 17

premysl.misun
Advocate
Advocate

Still same error...

0 Likes
Message 5 of 17

bradeneuropeArthur
Mentor
Mentor

Do you have installed inventor and what version?

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 6 of 17

bradeneuropeArthur
Mentor
Mentor

@premysl.misun

 

Take a look at the references for the project in VB.net.

 

like in the picture below.

 

Seems that the older version of inventor in missing now and need to be defined new with the new version of inventor.

 

RegardsReferencesNet.JPG

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 7 of 17

premysl.misun
Advocate
Advocate

I use Inventor Professional 2019. Before that I have 2017 and 2018. In old versions this program work.

I unistalled old versions (2017 and 2018). Maybe this is the problem.

 

In attachme are my references.

0 Likes
Message 8 of 17

premysl.misun
Advocate
Advocate

I can not find in COM  “Autodesk Inventor Object Library” 😕

0 Likes
Message 9 of 17

bradeneuropeArthur
Mentor
Mentor

then this is the issue.

make the reference and it will be solved….

 

C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Autodesk.Inventor.Interop\.............\Autodesk.Inventor.Interop.dll

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 10 of 17

premysl.misun
Advocate
Advocate

Unfortunately it not work :/.

 

I have version v4.0_23.1.0.0__d84147f8b4276564

0 Likes
Message 11 of 17

premysl.misun
Advocate
Advocate

List of my References in this project is in attachment

0 Likes
Message 12 of 17

premysl.misun
Advocate
Advocate

Any other solution?

0 Likes
Message 13 of 17

bradeneuropeArthur
Mentor
Mentor

What version of Visual Studio are you using?

 

Can you put this into a button definition and try what is happening?

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        Dim oApprenticeDocument As Inventor.ApprenticeServerDocument = Nothing

        Try
            Dim oApprenticeServerComponent = New Inventor.ApprenticeServerComponent
            MsgBox(oApprenticeServerComponent.UserName)

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

    End Sub

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 14 of 17

premysl.misun
Advocate
Advocate

I use Microsoft Visual Basic 2010 Express.

Your "button program" display error message. It is in attachment.

0 Likes
Message 15 of 17

bradeneuropeArthur
Mentor
Mentor

Do you have the correct frame work available.

seems that VS is a little to outdated?

 

.NET Framework Version 4.7 or later. Windows Updates enabled for installation.

 

https://knowledge.autodesk.com/support/inventor-products/troubleshooting/caas/sfdcarticles/sfdcartic...

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 16 of 17

premysl.misun
Advocate
Advocate

.Net Framework 4.7 installed and problem is the same.

 

Can be this done by uninstall of old versions of Inventor (2017 and 2018)?

0 Likes
Message 17 of 17

bradeneuropeArthur
Mentor
Mentor
Read this!
https://forums.autodesk.com/t5/inventor-customization/problems-with-inventor-apprentice/td-p/5183865

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