Inventor Customization

Inventor Customization

Reply
Distinguished Contributor
GeorgK
Posts: 155
Registered: ‎09-21-2006
Message 1 of 5 (301 Views)
Accepted Solution

Deactivate add-in with vba or vb.net

301 Views, 4 Replies
10-02-2012 02:55 AM

Hello together,

 

how can I deactivate an add-in with vba or vb.net?

 

Thank you

 

Georg

Hi Georg,

 

Here a VB.Net example with iLogic:

 

First, I create a module for the ItemByName extension (if you don't familiar with extension, read about it, it's a nice way of programming).

 

Public Module InventorExtensions
<Extension()> _
Function ItemByName(applicationAddIns As Inventor.ApplicationAddIns, displayName As String) As Inventor.ApplicationAddIn
For Each i As Inventor.ApplicationAddIn In applicationAddIns
If i.DisplayName = displayName Then
Return i
End If
Next
Return Nothing
End Function
End Module

 

Next, add this to your method:

 

Dim inventorApplication as Inventor.Application = System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application")
Dim iLogic as Inventor.ApplicationAddIn = InventorApplication.ApplicationAddIns.ItemByName("iLogic")
iLogic.Deactivate

 

 Give me feedback if it's what you need.

 

 

Pascal

Valued Contributor
planglais
Posts: 61
Registered: ‎03-10-2011
Message 2 of 5 (285 Views)

Re: Deactivate add-in with vba or vb.net

10-05-2012 06:15 AM in reply to: GeorgK

Hi Georg,

 

Here a VB.Net example with iLogic:

 

First, I create a module for the ItemByName extension (if you don't familiar with extension, read about it, it's a nice way of programming).

 

Public Module InventorExtensions
    <Extension()> _
    Function ItemByName(applicationAddIns As Inventor.ApplicationAddIns, displayName As String) As Inventor.ApplicationAddIn
        For Each i As Inventor.ApplicationAddIn In applicationAddIns
            If i.DisplayName = displayName Then
                Return i
            End If
        Next
        Return Nothing
    End Function
End Module

 

Next, add this to your method:

 

Dim inventorApplication as Inventor.Application = System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application")
Dim iLogic as Inventor.ApplicationAddIn = InventorApplication.ApplicationAddIns.ItemByName("iLogic")
iLogic.Deactivate

 

 Give me feedback if it's what you need.

 

 

Pascal

Valued Contributor
planglais
Posts: 61
Registered: ‎03-10-2011
Message 3 of 5 (283 Views)

Re: Deactivate add-in with vba or vb.net

10-05-2012 06:17 AM in reply to: planglais

I forgot this line of code:

 

   Imports InventorExtensions

 

Put this on the top of your document where your method is.

 

 

Pascal

Distinguished Contributor
GeorgK
Posts: 155
Registered: ‎09-21-2006
Message 4 of 5 (263 Views)

Re: Deactivate add-in with vba or vb.net

10-08-2012 01:52 AM in reply to: planglais

Hello Pascal,

 

thank you very much.

 

Georg

Valued Contributor
jonbrabbs
Posts: 76
Registered: ‎07-26-2007
Message 5 of 5 (257 Views)

Re: Deactivate add-in with vba or vb.net

10-08-2012 02:27 AM in reply to: GeorgK

Hi Georg,

 

To turn off addins before invetor starts, you need to fettle with the registry entries. To do this, you need to create a new class and add the following code:

 

Imports Microsoft.Win32
Public Class RegistryEntry
    Public Sub ChangeRegistryKey(ByVal strMainKey As String, ByVal StrOn As String)
        'MessageBox.Show("CLSID\{" & strMainKey & "}\Settings", "")
        Dim Autoshell As RegistryKey = My.Computer.Registry.ClassesRoot.OpenSubKey("CLSID\{" & strMainKey & "}\Settings", True)
        If Autoshell Is Nothing Then
            'Registy key does not exit - do nothing
        Else
            Autoshell.SetValue("LoadOnStartUp", StrOn)
            Autoshell.Close()
        End If
    End Sub
End Class

 

Then you need to find the registry key you want to change - a simple search through the registry for the name of the addin will get this.

 

Then, add the following lines of code to your program before you start inventor:

 

Dim AssemblyBonusTools As New RegistryEntry

AssemblyBonusTools.ChangeRegistryKey("0BB5AE99-15A3-4B00-9731-210ED5A4E7B2", 0/1)

 

The 0/1 element is a string I believe, but don't quote me on this.

 

Don't forget to turn any addins back on again once you've finished.

 

Hope this is of some use to you.

 

Jon

 

///////////////////////////////////////////////////////////////////////////////////////////////////
If this post helps you, please give kudos.
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.