MyFirstInventorPlug-in errors

MyFirstInventorPlug-in errors

johan.degreef
Advisor Advisor
891 Views
14 Replies
Message 1 of 15

MyFirstInventorPlug-in errors

johan.degreef
Advisor
Advisor

Am tryng to complete lesson 3 in MyFirst Inventor plugin

just copied the code from the lesson, but get several errors.

 

Does anybody have an idea what is wrong?

 

 

Imports System
Imports System.Type
Imports System.Activator
Imports System.Runtime.InteropServices
Imports Inventor

Public Class Form1
    Dim _invApp As Inventor.Application
    Dim _started As Boolean = False

    Public Sub New()

        ' This call is required by the designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.

        Try
            _invApp = Marshal.GetActiveObject("Inventor.Application")
        Catch ex As Exception
            Try
                Dim invAppType As Type =
                GetTypeFromProgID("Inventor.Application")

                _invApp = CreateInstance(invAppType)
                _invApp.Visible = True
                _started = True

            Catch ex2 As Exception
                MsgBox(ex2.ToString())
                MsgBox("Unable to get or start Inventor")
            End Try
        End Try
    End Sub

    Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        '  This will shut down the Inventor session started when the form was started
        If _started Then
            _invApp.Quit()
        End If

        _invApp = Nothing
    End Sub


End Class

 

 

Knipsel.JPG

Inventor 2025, Vault Professional 2025, Autocad Plant 3D 2025
0 Likes
Accepted solutions (1)
892 Views
14 Replies
Replies (14)
Message 2 of 15

bradeneuropeArthur
Mentor
Mentor

Hi Johan,

Have you all references set? Via project properties //references.

What framework are you using?

 

Let us clarify this per mail if you are fine?

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 15

etaCAD
Advocate
Advocate

To get rid of the first error please set a reference to Sytem.Runtime.InteropServices.

For both other errors I recommend to replace "MsgBox..." by "MessageBox.Show(...)" and add "Imports System.Windows.Forms" on top of your code. MsgBox is from old VB6.

 

You can also place your mouse pointer on the error in the code window, wait for the tooltip and have a look what VS proposes how to fix this issue.

 

Andreas
etaCAD

Message 4 of 15

bradeneuropeArthur
Mentor
Mentor

Hi @johan.degreef 

With these references set it should work:

bradeneuropeArthur_0-1615795758364.png

 

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 5 of 15

johan.degreef
Advisor
Advisor

Still som errors

Knipsel.JPG

 
Inventor 2025, Vault Professional 2025, Autocad Plant 3D 2025
0 Likes
Message 6 of 15

bradeneuropeArthur
Mentor
Mentor

can you show me the references dialog again?

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 15

johan.degreef
Advisor
Advisor

Knipsel.JPG

Inventor 2025, Vault Professional 2025, Autocad Plant 3D 2025
0 Likes
Message 8 of 15

johan.degreef
Advisor
Advisor

But if I start a new project what should I select?

 

Knipsel.JPG

 

 

Inventor 2025, Vault Professional 2025, Autocad Plant 3D 2025
0 Likes
Message 9 of 15

bradeneuropeArthur
Mentor
Mentor

For an Add In and you should select "Autodesk Inventor 2021 VB Addin".

For a standalone app like your first code you need different for example a Windows Form.

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

Message 10 of 15

johan.degreef
Advisor
Advisor

Can you see which template is used in an existing project?

 

If I create a new Windows Form project I cannot use 4.7.1 . NET, which seems to be the correct one?

biogas1.JPG

Inventor 2025, Vault Professional 2025, Autocad Plant 3D 2025
0 Likes
Message 11 of 15

bradeneuropeArthur
Mentor
Mentor

What version of Visual studio are you using?

 

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 12 of 15

johan.degreef
Advisor
Advisor

@bradeneuropeArthur 

Visual Studio Community2019

Inventor 2025, Vault Professional 2025, Autocad Plant 3D 2025
0 Likes
Message 13 of 15

bradeneuropeArthur
Mentor
Mentor
Accepted solution

That could be to heigh for inventor 2021.

Vs2017 may better.

I will check for you ASAP.

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 15

bradeneuropeArthur
Mentor
Mentor

Should be OK.

 

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

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

johan.degreef
Advisor
Advisor

Uninstalled 2019, installed 2017, done the same excercise, and it all works...

Inventor 2025, Vault Professional 2025, Autocad Plant 3D 2025
0 Likes