Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

how to listen click event of addin tab?

13 REPLIES 13
Reply
Message 1 of 14
liminma8458
1036 Views, 13 Replies

how to listen click event of addin tab?

Hi, all,
I am developing an addin. I want to listen to click event of the addin tab to show some message before it shows the below ribbon panels and buttons. Is there any click event for the tab? how can I do it?

Thanks
Limin
Inventor pro 2023 64 bit update 2.1; Windows 10 pro 64 bit version 21H2; Office 2013 32 bit
13 REPLIES 13
Message 2 of 14
liminma8458
in reply to: liminma8458

The attached file shows the tab I want to listen to its click event, or any default tab such as "Tools" or "Manage". Any one can help?

Thanks
Limin
Inventor pro 2023 64 bit update 2.1; Windows 10 pro 64 bit version 21H2; Office 2013 32 bit
Message 3 of 14
YuhanZhang
in reply to: liminma8458

Unfortunately we don't have the event for click/activate the ribbon tab at present. I am curious about why you want this, maybe you need to do some check before showing some panels/buttons, can you explain more details about what you want to do?



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

Message 4 of 14
liminma8458
in reply to: YuhanZhang

Yes. I want to check whether there are more than one Inventor instance open before showing the custom addin panels/buttons. Our addin program only works with one Inventor instance open. But sometimes designers run the program while having 2 or more Inventor instances open, thus causing failure of the program.

 

Do you have any suggestion on this?

Thanks
Limin
Inventor pro 2023 64 bit update 2.1; Windows 10 pro 64 bit version 21H2; Office 2013 32 bit
Message 5 of 14
YuhanZhang
in reply to: liminma8458

I don't know how your program works with Inventor, if your program is something like Vault to deal with inventor data, that you can make your data as CheckedIn/CheckedOut to indicate if your current Inventor instance can work on the data. Maybe you can also add an indicator in your program so your addin can check if your program is connecting to current Inventor instance, so you can decide if you will show the ribbon controls(I suggest to always show the controls but you can disable them if you don't want users to use them in some cases). Or if you can tell more details about your program we can find a better suggestion maybe.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

Message 6 of 14

Hi,

 

Maybe I don't understand correctly, but if you are using the "Inventor Application" of your a addin there is no possibility that the other inventor session is used.

Like this:

Private m_inventorApplication As Inventor.Application

Public Sub Activate(ByVal addInSiteObject As Inventor.ApplicationAddInSite, ByVal firstTime As Boolean) Implements Inventor.ApplicationAddInServer.Activate

m_inventorApplication = addInSiteObject.Application End sub

With this  method the situation you have is impossible!

 

How are you declaring your "Inventor Application"?

 

Regards,

 

 

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
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: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 !

Message 7 of 14
liminma8458
in reply to: YuhanZhang

To YuHanZhang: Our Addin is a registered DLL addin. It will automatically load with every Inventor session. We do not use Vault. We always open Inventor using a project file. I am currently visiting China, are you in China? If yes, what is your email address, we can arrange a remote desktop to see my application scenario.

 

To bradeneurope|Arthur: we use your way to get “m_inventorApplication” when defining the addin tab, panels and buttons. But the buttons will call sub DLLs to execute their functions. In the sub DLLs, we use <ThisApplication = Marshal.GetActiveObject("Inventor.Application")> to get ThisApplication directly (may be this is the reason the program loses the track which inventor session it is using. We do not pass the Inventor instance as a parameter from top DLL to sub DLL. Is it?)

Thanks
Limin
Inventor pro 2023 64 bit update 2.1; Windows 10 pro 64 bit version 21H2; Office 2013 32 bit
Message 8 of 14
YuhanZhang
in reply to: liminma8458

So your problem is that you use the GetActiveObject to get the Inventor application which maybe not the one the addin is loaded in, I think you need to pass the Inventor which you are interested to the functions(from other DLLs) you want to call, this is good practice. Is there any reason that you don't want to pass the Inventor application?



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

Message 9 of 14

Hi,

 

For an addin "<ThisApplication = Marshal.GetActiveObject("Inventor.Application")" is not a good practice.

This is actually the problem I assume.

 

If you use the m_inventorapplication method the application is fix.

With your method it is random and not fix.

 

Regards,

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2024 | Vault Professional 2022 | Autocad Mechanical 2022
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: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 !

Message 10 of 14
liminma8458
in reply to: YuhanZhang

As I mentioned my addin loads on every Inventor session's interface and shows in addin manager. Do you mean "GetActiveObject" will mess up in which Inventor session should the addin (and sub abbins) run consistantly? and the other way will always keep the handle of the same Inventor Instance (session)?

 

The reason I use "GetActiveObject" in each addin instead of passing "ThisApplication" as parameter to sub addin is of simplicity of code.

 

I will try "addInSiteObject" to see what happen.

Thanks
Limin
Inventor pro 2023 64 bit update 2.1; Windows 10 pro 64 bit version 21H2; Office 2013 32 bit
Message 11 of 14
YuhanZhang
in reply to: liminma8458

Correct, the GetActiveObject will find an Inventor instance in the ROT(Running Object Table), but if you have multiple Inventor instances in the ROT, the method can't guarantee that it always returns the same Inventor instance that you want. To avoid the issue, the good practice is to pass the Inventor Application from the ApplicationAddinSite to your other classes or dlls. You can find some sample VS projects in the Inventor SDK, they may help you to know how to do it, you can install the DeveloperTools.msi from C:\Users\Public\Documents\Autodesk\Inventor 2020\SDK\, then you can find the addin samples in different languages(VB, C# and C++) . For example the one in VB:

 

    C:\Users\Public\Documents\Autodesk\Inventor 2020\SDK\DeveloperTools\Samples\VB.NET\AddIns\SimpleAddIn

 

you can see the below code in the StandardAddInServer.vb which passes the Application to other class:

 

Button.InventorApplication = m_inventorApplication

 

Hope this helps.



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

Message 12 of 14
liminma8458
in reply to: liminma8458

I found this post that may be able to intercept the click of an addin tab from Philippe Leefsma ("How to intercept a click event on a custom ribbon tab"). 

https://forums.autodesk.com/t5/inventor-customization/how-to-intercept-a-click-event-on-a-custom-rib...

But the code is in C#.  For a long time I haven't practiced C language. I don't know someone can help to cover this to VB.NET. I think that will help people with similar request as mine.

 

 

 

Thanks
Limin
Inventor pro 2023 64 bit update 2.1; Windows 10 pro 64 bit version 21H2; Office 2013 32 bit
Message 13 of 14
liminma8458
in reply to: YuhanZhang

I found this post that may be able to intercept the click of an Addin tab from Philippe Leefsma ("How to intercept a click event on a custom ribbon tab").

https://forums.autodesk.com/t5/inventor-customization/how-to-intercept-a-click-event-on-a-custom-rib...

https://forums.autodesk.com/t5/inventor-chan-pin-ji-shu-ying-yong-tao-lun-qu/inventor-ji-qiao-huo-qu...

But the code is in C#.  For a long time I haven't practiced C. Can someone help convert this short script into VB.NET? I think that will also help people with similar request as mine.

Thank you so much!

Thanks
Limin
Inventor pro 2023 64 bit update 2.1; Windows 10 pro 64 bit version 21H2; Office 2013 32 bit
Message 14 of 14
liminma8458
in reply to: YuhanZhang

Hi, Rocky,

Could you help to convert this short C# script into VB.NET? very much appreciated

Thanks
Limin
Inventor pro 2023 64 bit update 2.1; Windows 10 pro 64 bit version 21H2; Office 2013 32 bit

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report