What are everybody's preferred way to test their add-on progress. I am currently using a symbolic link to reference my build output directly to the add-on folder and have no issues when creating a new part to see my progress. The one issue I am having is returning to a part I created and having my add-on grayed out. I'm not sure if this is due to my code or if it is because I am checking it out from M-Files but I seem to be missing something for my add-on to be enabled again.
I used Bolsover's Adventures as a reference. It has been great so far! Just this one small hiccup.
Here is my add-on code so far.
I used Bolsover's Adventures as a reference. It has been great so far! Just this one small hiccup.
Here is my add-on code so far.
C#:
using AlibreAddOn;
using AlibreX;
using System;
using System.Windows;
namespace KageInnovation
{
public class CADPackAutonesting : IAlibreAddOn
{
private const int MenuIdRoot = 402;
private IADRoot _alibreRoot;
private IntPtr _parentWinHandle;
public CADPackAutonesting(IADRoot alibreRoot, IntPtr parentWinHandle)
{
this._alibreRoot = alibreRoot;
this._parentWinHandle = parentWinHandle;
}
public int RootMenuItem => MenuIdRoot;
public bool HasPersistentDataToSave(string sessionIdentifier)
{
return false;
}
public bool HasSubMenus(int menuID)
{
return false;
}
public IAlibreAddOnCommand InvokeCommand(int menuID, string sessionIdentifier)
{
var session = _alibreRoot.Sessions.Item(sessionIdentifier);
MessageBox.Show(session.Name);
return null;
}
public void LoadData(IStream pCustomData, string sessionIdentifier)
{
}
public string MenuIcon(int menuID)
{
return string.Empty;
}
public ADDONMenuStates MenuItemState(int menuId, string sessionIdentifier)
{
var session = _alibreRoot.Sessions.Item(sessionIdentifier);
switch (session)
{
case IADDrawingSession:
switch (menuId)
{
case MenuIdRoot: return ADDONMenuStates.ADDON_MENU_ENABLED;
}
break;
case IADAssemblySession:
switch (menuId)
{
case MenuIdRoot: return ADDONMenuStates.ADDON_MENU_ENABLED;
}
break;
case IADPartSession:
switch (menuId)
{
case MenuIdRoot: return ADDONMenuStates.ADDON_MENU_ENABLED;
}
break;
}
return ADDONMenuStates.ADDON_MENU_ENABLED;
}
public string MenuItemText(int menuID)
{
return "Autonest";
}
public string MenuItemToolTip(int menuID)
{
return "";
}
public bool PopupMenu(int menuID)
{
return false;
}
public void SaveData(IStream pCustomData, string sessionIdentifier)
{
}
public void setIsAddOnLicensed(bool isLicensed)
{
}
public Array SubMenuItems(int menuID)
{
return null;
}
public bool UseDedicatedRibbonTab()
{
return false;
}
}
}