Add-Ins for Inventor 2015 with VB.NET 2015

Add-Ins for Inventor 2015 with VB.NET 2015

Anonymous
Not applicable
632 Views
3 Replies
Message 1 of 4

Add-Ins for Inventor 2015 with VB.NET 2015

Anonymous
Not applicable

Hello:

 

I am really struggling with the tutorial called "Taking the Step from VBA to Autodesk Inventor Add-ins.

 

I am on page 15 of this document, where I am trying to add a button.  

 

You can see by the attached image, that there are some underlines that represent that this example p[lainly does not work out.  It is really demotivating to try and do examples completely by the book, and see them fail.   

 

Has anyone written an up-to-date book on Add-Ins?  It seems like there is less support for this than there was ten years ago.  

 

Code is below:

 

 

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

Namespace InventorAddIn1
    <ProgIdAttribute("InventorAddIn1.StandardAddInServer"), _
    GuidAttribute("3e6f8cdf-5b3f-41f2-a768-51f88f4e23be")> _
    Public Class StandardAddInServer
        Implements Inventor.ApplicationAddInServer

        ' Inventor application object.
        Private m_inventorApplication As Inventor.Application

        ' ADDED FOR BUTTON
        Private WithEvents m_uiEvents As UserInterfaceEvents
        Private WithEvents m_samplebutton As ButtonDefinition


#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.
            m_inventorApplication = addInSiteObject.Application

            ' Connect to the user-interface events to handle a ribbon reset.
            m_uievents = m_inventorApplication.UserInterfaceManager.UserInterfaceEvents

            ' TODO:  Add ApplicationAddInServer.Activate implementation.
            ' e.g. event initialization, command creation etc.
            Dim largeIcon As stdole.IPictureDisp = PictureDispConverter.ToIPictureDisp(My.Resources.YourBigImage)
            Dim smallIcon As stdole.IPictureDisp = PictureDispConverter.ToIPictureDisp(My.Resources.YourSmallImage)

            ' ADDED FOR BUTTON
            Dim controlDefs As Inventor.ControlDefinitions = m_inventorApplication.CommandManager.ControlDefinitions
            m_samplebutton = controlDefs.AddButtonDefinition("Command Name", "Internal name", CommandTypesEnum.kShapeEditCmdType, AddInClientID)

        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

            ' Release objects.
            m_inventorApplication = Nothing

            System.GC.Collect()
            System.GC.WaitForPendingFinalizers()
        End Sub

        Public ReadOnly Property Automation() As Object Implements Inventor.ApplicationAddInServer.Automation

            ' This property is provided to allow the AddIn to expose an API 
            ' of its own to other programs. Typically, this  would be done by
            ' implementing the AddIn's API interface in a class and returning 
            ' that class object through this property.

            Get
                Return Nothing
            End Get

        End Property

        Public Sub ExecuteCommand(ByVal commandID As Integer) Implements Inventor.ApplicationAddInServer.ExecuteCommand

            ' Note:this method is now obsolete, you should use the 
            ' ControlDefinition functionality for implementing commands.

        End Sub

#End Region

    End Class

End Namespace

Screen Shot 07-06-16 at 12.50 PM.JPG

 

0 Likes
633 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable

I THINK IT IS ABSOLUTELY INSANE THAT NO ONE CAN ANSWER THIS QUESTION, REGARDING AUTODESKS OWN DOCUMENT EXAMPLE FOR USING ADD-INS.  I CAN ONLY CONCLUDE THAT IT DOES NOT WORK, OR YOU DO NOT REALLY WANT PEOPLE USING IT.  I SUPPOSE I CAN DEFAULT BACK TO A STAND-ALONE PROGRAM.

 

YOUR SOFTWARE IS OUTRAGEOUS, AND THE SUPPORT SUCKS!

 

0 Likes
Message 3 of 4

pball
Mentor
Mentor
This is a user forum where users help other users. This is not an official support forum, though Autodesk employees do post some times. If you want official support go through your reseller or the support ticket system if you have a subscription account.

As to some of the errors in the picture above. Do you have pictures added as resources called YourBigImage and YourSmallImage? Do you have a function called PictureDispConverter anywhere? AddInClientID is another function that is required.

The two functions I mentioned were included in the VB addin template that the SDK installed for me. The pictures you need to add yourself if you haven't.
Check out my style edits for the Autodesk forums
pball's Autodesk Forum Style
0 Likes
Message 4 of 4

Anonymous
Not applicable

Thanks for your reply, and sorry for my Rant.  I thought this was the Autodesk support site.  Perhaps a disclosure and removal of the Autodesk logo would be appropriate.  

 

 

 

0 Likes