Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have previously had a multiple successful Add-ins created using VB.net. I was told I need to start writing them in C# so our IT department can better assist. The build is successful, it opens inventor, shows in the Add-in manager, however it won't populate the button in any ribbon. I have all functions called out same as in the VB.net Add-ins just translated to C# language. Below is the full 'StandardAddInServer.cs" file any assistance would be greatly appreciated.
using Inventor;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Runtime.InteropServices;
namespace Furnace
{
/// <summary>
/// This is the primary AddIn Server class that implements the ApplicationAddInServer interface
/// that all Inventor AddIns are required to implement. The communication between Inventor and
/// the AddIn is via the methods on this interface.
/// </summary>
[GuidAttribute("431205c6-c088-422e-82de-9bf8b0801f0c")]
public class StandardAddInServer : Inventor.ApplicationAddInServer
{
// Inventor application object.
private Inventor.Application m_inventorApplication;
private UserInterfaceEvents m_uiEvents;
private Inventor.ButtonDefinition buttonDefinition;
private object AddClientID;
public StandardAddInServer()
{
}
#region ApplicationAddInServer Members
public void Activate(Inventor.ApplicationAddInSite addInSiteObject, bool firstTime)
{
// 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;
m_uiEvents = m_inventorApplication.UserInterfaceManager.UserInterfaceEvents;
ControlDefinitions controlDefs = m_inventorApplication.CommandManager.ControlDefinitions;
//IPictureDisp smallimage =
var commandManager = m_inventorApplication.CommandManager;
buttonDefinition = commandManager.ControlDefinitions.AddButtonDefinition("Furnace Automation", "Automation", CommandTypesEnum.kQueryOnlyCmdType, AddClientID);
// Connect to the user-interface events to handle a ribbon reset.
buttonDefinition.OnExecute += ButtonDefinition_OnExecute;
buttonDefinition.AutoAddToGUI();
if (firstTime)
{
AddToUserInterface();
}
}
private void ButtonDefinition_OnExecute(NameValueMap Context)
{
throw new NotImplementedException();
}
public void 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 = null;
m_uiEvents = null;
buttonDefinition = null;
buttonDefinition.OnExecute -= ButtonDefinition_OnExecute;
GC.Collect();
GC.WaitForPendingFinalizers();
}
public object 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
{
// TODO: Add ApplicationAddInServer.Automation getter implementation
return null;
}
}
#endregion
#region User interface definition
private void AddToUserInterface()
{
Ribbon ZeroLoc = m_inventorApplication.UserInterfaceManager.Ribbons["ZeroDoc"];
RibbonTab ToolLoc = ZeroLoc.RibbonTabs["id_TabTools"];
string ClientID = null;
RibbonPanel FinalLoc = ToolLoc.RibbonPanels.Add("Furnace Automation", "Automation2", ClientID);
FinalLoc.CommandControls.AddButton(buttonDefinition);
}
public void ExecuteCommand(int CommandID)
{
throw new NotImplementedException();
}
#endregion
}
}
Solved! Go to Solution.