Inventor Vb.Net "AddIn" - Show "oDoc.Displayname" Using A Button Click

Inventor Vb.Net "AddIn" - Show "oDoc.Displayname" Using A Button Click

isocam
Collaborator Collaborator
353 Views
9 Replies
Message 1 of 10

Inventor Vb.Net "AddIn" - Show "oDoc.Displayname" Using A Button Click

isocam
Collaborator
Collaborator

Can anybody help?

 

I have created a Vb.Net "AddIn" that automatically creates a button that calls a simple sub-routine.

 

I want to change the sub-routine, for testing purposes, so that it shows the oDoc.Displayname.

 

The following is the code I currently have but it is not working.

 

Imports Inventor

 

Module Module12
Sub ControlPanel()

Dim invApp As Inventor.Application = Nothing

invApp = GetObject(, "Inventor.Application")

oDoc = oInvApp.ActiveDocument

Msgbox(oDoc.Displayname)
End Sub

End Module

Does anybody know what is wrong and rectify the error for me?

 

Many thanks in advance!

 

Darren

0 Likes
354 Views
9 Replies
Replies (9)
Message 2 of 10

cidhelp
Advocate
Advocate

oDoc = invApp.ActiveDocument

0 Likes
Message 3 of 10

isocam
Collaborator
Collaborator

Hi,

 

Unfortunately, this does not work.

 

Can you please help?

 

Kind Regards

 

Darren

0 Likes
Message 4 of 10

jjstr8
Collaborator
Collaborator

It would help to have a little more information: e.g. version, what's not working, etc. @cidhelp pointed out the typo, but it's not clear what's going wrong. Also, an addin doesn't need to get the Inventor application object. It's passed into your ApplicationAddInServer implementation. Is this a standalone application?

0 Likes
Message 5 of 10

isocam
Collaborator
Collaborator

Hi,

 

Many thanks for the reply!

 

I have created an "AddIn" for Autodesk Inventor 2025.

 

The sub-routine is called by pressing a custom button.

 

At present, I have just created a message box stating "Hello World". and this is correctly displayed when I press the button.

 

All I need, for testing purposes, is to display the filename of the active document when I press the button.

 

For some reason, the message box is not showing

 

Can you please help?

 

Many thanks in advance!

 

Darren

0 Likes
Message 6 of 10

jjstr8
Collaborator
Collaborator

I still get the feeling that you have a stand-alone application (exe), not an addin (dll). See this link for a description.

https://help.autodesk.com/view/INVNTOR/2025/ENU/?guid=GUID-4939ABD1-A15E-473E-9376-D8208EC029EB 

 

If you do indeed have a stand-alone application, check the solution in this post for retrieving the Inventor application object in .NET Core. Your application needs to be .NET 8, not a .NET Framework application.

https://forums.autodesk.com/t5/inventor-programming-ilogic/debugging-in-the-newer-version-of-net-in-... 

0 Likes
Message 7 of 10

isocam
Collaborator
Collaborator

Hi,

 

I have created an "AddIn" dll file, not a stand alone exe.

 

Kind Regards

 

Darren

0 Likes
Message 8 of 10

jjstr8
Collaborator
Collaborator

Please check the following link.

https://help.autodesk.com/view/INVNTOR/2025/ENU/?guid=GUID-52422162-1784-4E8F-B495-CDB7BE9987AB

 

Inventor will pass an ApplicationAddInSite object into your addin when it calls the Activate method in your implementation. From there you can get the Application object. You do not need to use GetObject or Marshal.GetActiveObject to get the Inventor application object.

jjstr8_0-1730834250592.png

 

0 Likes
Message 9 of 10

JelteDeJong
Mentor
Mentor

You might want to have a look at my tutorial about creating addins.

http://hjalte.nl/tutorials/80-creating-an-addin-inventor-2025-and-later 

There you will find a explanation on how to create buttons how to get the inventor object. (Getting the Inventor object using the marshal like you did is possible but make your addin run slow. You can better use the object provided by Inventor when you addin is started.)

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 10 of 10

marcin_otręba
Advisor
Advisor

Maybe try to declare oDoc first like:

Dim oDoc As Document = oinvApp.ActiveDocument

 

also as mentioned use 

invApp= addInSiteObject.Application

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

0 Likes