Message 1 of 14
Add-in creating a button
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi there!
I'm trying to create an addin with a button, I earlier created an addin that did some behind the scene's work and no button pressing was required, only a trigger. But now I want to add a button in the ribbon.
I tried follow this document from AU thats stored on the modthemachine website (see link)
http://modthemachine.typepad.com/files/VBAtoAddIn.pdf
So what I did:
- Opened my previous solution, I figured you can have more than one method in a add-in right?
- I added the code for creating button.
Namespace EMIA_001
<ProgIdAttribute("EMIA_001.StandardAddInServer"), _
GuidAttribute("f3ba742e-959e-4763-a2ea-864d85f4fd2b")> _
Public Class StandardAddInServer
Implements Inventor.ApplicationAddInServer
' Inventor application object.
Private m_inventorApplication As Inventor.Application
' Application Events object.
Private m_AppEvents As ApplicationEvents
' ClientID varialble
Private m_ClientID As String
' Main orientation button with event
Private WithEvents m_MainOrientationButtonDef 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
' TODO: Add ApplicationAddInServer.Activate implementation.
' e.g. event initialization, command creation etc.
' Get the classID for this add-in and save it in a
' member variable to use whenever a ClientID is needed
m_ClientID = addinguid(GetType(StandardAddInServer))
' Create the button definition
Dim controlsdefs As ControlDefinitions
controlsdefs = m_inventorApplication.CommandManager.ControlDefinitions
m_MainOrientationButtonDef = controlsdefs.AddButtonDefinition("Main orientation",
"emToolMainOrientation",
CommandTypesEnum.kQueryOnlyCmdType,
m_ClientID,
"Place the main orientation on the selected centermark",
"Place orientation")
If firstTime Then
' Create a new command bar (toolbar) and make it visible
Dim commandbars As CommandBars
commandbars = m_inventorApplication.UserInterfaceManager.CommandBars
Dim commandbar As CommandBar
commandbar = commandbars.Add("EM Tools", "emToolsBar", CommandBarTypeEnum.kRegularCommandBar, m_ClientID)
commandbar.Visible = True
' Add the control to the command bar
commandbar.Controls.AddButton(m_MainOrientationButtonDef)
End If
' Add event handler for save event.
m_AppEvents = m_inventorApplication.ApplicationEvents
AddHandler m_AppEvents.OnSaveDocument, AddressOf Me.m_ApplicationEvents_OnSaveDocument
End Sub
....... some more subs from template
But.. nothing is happening.. I can't see my button 😞 and my addin is not loaded anymore. as I check the addins at runtime.
What am I doing wrong here?
Some advice would be helpfull.
Please kudo if this post was helpfull
Please accept as solution if your problem was solved
Inventor 2014 SP2