Message 1 of 4
Add-Ins for Inventor 2015 with VB.NET 2015

Not applicable
07-06-2016
10:52 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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