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: 

Deactivate Object Not Working

4 REPLIES 4
Reply
Message 1 of 5
bradeneuropeArthur
325 Views, 4 Replies

Deactivate Object Not Working

Deactivation these after deactivate does not work

 

oTab = Nothing

 

When I start the Addin again the tab is still there after deactivate.

 

What is wrong in the code.

Public Sub SetupUserInterface(ByVal addInSiteObject As Inventor.ApplicationAddInSite, ByVal firstTime As Boolean, ClientID As String)

oTab = oRibbon.RibbonTabs.Add(sName & "", "AknoorsMasterAddIn" & "", ClientID)

End Sub

Public Sub Deactivate() Implements Inventor.ApplicationAddInServer.Deactivate

            ' This method is called by Inventor when the AddIn is unloaded.
            ' The AddIn will be unloaded either manually by the user or
            ' when the Inventor session is terminated.

            ' TODO:  Add ApplicationAddInServer.Deactivate implementation

            m_inventorApplication = Nothing

            oTab = Nothing

            System.GC.WaitForPendingFinalizers()
            System.GC.Collect()

End Sub

 

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 !

4 REPLIES 4
Message 2 of 5

Consider adding the following into Deactivate() implementation:

....

oTab.Delete()

oTab = Nothing

...

Thank you,




Alex Korzun
Inventor-Revit Interop / Inventor-Fusion Interop / Inventor ETO
Autodesk, Inc.

Message 3 of 5

Also then it is not released.

when you enable the add in again then the Tab is still in there and gives an error.

 

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

I tested the .Delete call, and it works.

Created an assembly, and added two rules into it:

  1. AddRibbonTab
    Dim rib As Ribbon = ThisApplication.UserInterfaceManager.Ribbons("Assembly")
    
    Dim test As RibbonTab = rib.RibbonTabs.Add("Test","{A4C2F061-0DC3-46A5-8B31-508938EDB5B1}", "{A4C2F061-0DC3-46A5-8B31-508938EDB5B1}")
    
    Dim panel As RibbonPanel = test.RibbonPanels.Add("Update", "{DF5AA47C-1858-41D7-92B9-CB4BBB1BADF3}", "{A4C2F061-0DC3-46A5-8B31-508938EDB5B1}")
    
    Dim button As ButtonDefinition = ThisApplication.CommandManager.ControlDefinitions.Item("AppLocalUpdateCmd")
    panel.CommandControls.AddButton(button, True)
    
    AlexKorzun_0-1617310828925.png

    The Tool tab is created with Update command in it

  2. DeleteRibbonTab
    Dim rib As Ribbon = ThisApplication.UserInterfaceManager.Ribbons("Assembly")
    
    Dim test As RibbonTab = rib.RibbonTabs("{A4C2F061-0DC3-46A5-8B31-508938EDB5B1}")
    
    test.Delete()

The "Test" tab is removed.

 

The rules should be run one after another.
Otherwise, the first rule fails on the second run, as RibbonTab is attempted to be created the second time.
The second rule will fail on the second run, in attempt to find non-existent RibbonTab. 

Thank you,




Alex Korzun
Inventor-Revit Interop / Inventor-Fusion Interop / Inventor ETO
Autodesk, Inc.

Message 5 of 5

The deletes you do in the deactivate routine?

 

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 !

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report