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: 

AddIn Activate Function Question

7 REPLIES 7
Reply
Message 1 of 8
rob.j.ross
654 Views, 7 Replies

AddIn Activate Function Question

I am new to creating .NET AddIns for Inventor so this is probably an easy answer.

 

As a test I created an AddIn that simply displays a form and added a button that outputs "Hello" when clicked.  The AddIn loads fine in Inventor(see Loaded.png).  When I debug the AddIn it does not seem as though any code in the "Activate" function gets ran.  This is where I want to create the control definitions and add the ribbon button correct?  Am I missing something here?

 

StandardAddInServer.vb Code is below:

 

Imports Inventor
Imports System.Runtime.InteropServices
Imports Microsoft.Win32

Namespace TestAddIn

    <ProgIdAttribute("TestAddIn.StandardAddInServer"), _
    GuidAttribute("856d6ece-8c6a-41c4-a904-b96f02162008")> _
    Public Class StandardAddInServer

        Implements Inventor.ApplicationAddInServer

#Region "ApplicationAddInServer Members"

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

            ' This method is called by Inventor when it loads the AddIn.
            ' The AddInSiteObject provides access to the Inventor Application object.
            ' The firstTime flag indicates if the AddIn is loaded for the first time.

            ' Initialize AddIn members. - Not used
            ' m_InventorApplication = addInSiteObject.Application

            MsgBox("Test")

            ' TODO:  Add ApplicationAddInServer.Activate implementation.
            ' e.g. event initialization, command creation etc.

        End Sub

 Note that I am not using m_Inventor Application and instead using the global g_InventorApplication as suggested by Brian in another thread.

 

End Namespace

Public Module Globals

    Public g_InventorApplication As Inventor.Application

End Module

 The startup form is set as Form1. (see Project.png)

____________________________
Inventor Professional 2014 64 Bit
Windows 7 Professional
NVIDIA Quadro FX 4600
Dual Intel Xeon E5540 CPUs
16GB DDR3 Ram
7 REPLIES 7
Message 2 of 8

In the compile window, make sure the make COM visible is check.

Also make sure the .addin file is with the other addin files, usually in programdata folder.

Make sure the path in the addin file is correct.

 

 

Message 3 of 8

I don't see where the COM visible option is.  I am using VS 2010.  See the attached SS.

 

Also does the AddIn go in:

 

C:\Users\rob\AppData\Roaming\Autodesk\Inventor 2014\Addins

 

or

 

C:\Users\rob\AppData\Roaming\Autodesk\ApplicationPlugins\TestAddIn

 

I believe it can go in either.

 

 

____________________________
Inventor Professional 2014 64 Bit
Windows 7 Professional
NVIDIA Quadro FX 4600
Dual Intel Xeon E5540 CPUs
16GB DDR3 Ram
Message 4 of 8

Check if you have the C:\ProgramData\Autodesk\Inventor 2014\Addins and make sure the addin file is NOT in the ROAMING folders.

 

See the pict for the COM.

 

Message 5 of 8

I moved the AddIn to the ProgramData location you suggested.

 

The COM visible option is checked.

 

What is the path for the Build Output location under compile?

____________________________
Inventor Professional 2014 64 Bit
Windows 7 Professional
NVIDIA Quadro FX 4600
Dual Intel Xeon E5540 CPUs
16GB DDR3 Ram
Message 6 of 8
rob.j.ross
in reply to: rob.j.ross

The AddIn help file suggests putting the .addin file and .dll file in the "Roaming" folder for drag and drop deployment.  See the attached screen capture.  The AddIn loads fine following this method.

____________________________
Inventor Professional 2014 64 Bit
Windows 7 Professional
NVIDIA Quadro FX 4600
Dual Intel Xeon E5540 CPUs
16GB DDR3 Ram
Message 7 of 8
rob.j.ross
in reply to: rob.j.ross

In the activate function of many AddIn examples there is a variable for the client ID denoted as m_ClientID

this is usually defined as:

 

m_ClientID = AddInGuid(GetType(StandardAddInServer))

 

What is the code for the AddInGuid function?  I could not find this defined anywhere.

 

I can get the value for the client ID and set it but would like to use the function.

____________________________
Inventor Professional 2014 64 Bit
Windows 7 Professional
NVIDIA Quadro FX 4600
Dual Intel Xeon E5540 CPUs
16GB DDR3 Ram
Message 8 of 8
mr_ensing
in reply to: rob.j.ross

I'm trying to create an add-in from some VBA code myself and figuring this all out as i go. 

That AddInGuid function took me some time too. It is found in the VBAtoAddIn.pdf. If you check this post and download the sample files, open the ClassSample project in there. At the bottom of StandardAddInServer.vb you'll find: 

 

        ' This property uses reflection to get the value for the GuidAttribute attached to the class.
        Public Shared ReadOnly Property AddInGuid(ByVal t As Type) As String
            Get
                Dim guid As String = ""
                Try
                    Dim customAttributes() As Object = t.GetCustomAttributes(GetType(GuidAttribute), False)
                    Dim guidAttribute As GuidAttribute = CType(customAttributes(0), GuidAttribute)
                    guid = "{" + guidAttribute.Value.ToString() + "}"
                Finally
                    AddInGuid = guid
                End Try
            End Get
        End Property

 So there.

(A late reply, but who knows, maybe someone starts googleing and ends up here like i did.)

 

 

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

Post to forums  

Autodesk Design & Make Report