Solid Edge Addin for command bar in C#

Hi Jason and RD,

Do you have Solid Edge addin example for command bar in C# similar to VC++ addin example(C:\Program Files\Solid Edge ST4\SDK\Samples\Addins\VC)?

 

Thank you,

Amit

 

Posted by: Amit Wadekar
Post date: 4/20/2012 3:45:54 AM

1 REPLY

Re: Solid Edge Addin for command bar in C#

don't have a clean full example but here is the basics for it (nor did I tested this)

you can have a more info (much more detailed under "Solid Edge ST4\SDK\Samples\Addins\Doc" )

 

namespace ureProjNameSapce
    [GuidAttribute("2A24FC8D-36EE-4967-BAA0-22E584B9149B"),
      ProgId("MyAddIn.Addin"),
      ComVisible(true)]
    public class AddIn : SolidEdgeFramework.ISolidEdgeAddIn
    {
        private SolidEdgeFramework.AddIn m_addin;
        private SolidEdgeFramework.Application m_application;
        private SolidEdgeFramework.DISEApplicationEvents_Event appEvents;
        private SolidEdgeFramework.DISEAddInEvents_Event addinEvents;
 public void OnConnection(object Application, SolidEdgeFramework.SeConnectMode ConnectMode, SolidEdgeFramework.AddIn AddInInstance)
        {
            // Store local variables for later use
            m_addin = AddInInstance;
            m_application = (SolidEdgeFramework.Application)Application;
            // Set Addin's GUI Version
            AddInInstance.GuiVersion = 1;

            // Get a reference to the application events
            appEvents = (SolidEdgeFramework.DISEApplicationEvents_Event)m_application.ApplicationEvents;
            //hang events here..
       }

 public void OnConnectToEnvironment(string EnvCatID, object pEnvironmentDispatch, bool bFirstTime)
        {
            try
            {
                string[] commandNames = new string[5];
                commandNames[0] = "cmdAbout\n\nAbout System\nAbout";
                commandNames[1] = "cmdTester\n\nTester\nDebug";
                
                int[] commandIDs = new int[5];
                commandIDs[0] = 101;
                commandIDs[1] = 102;
              
                //on every entry to enviroment (part/assembly/etc..) this func is called..
                m_addin.SetAddInInfo(Marshal.GetHINSTANCE(this.GetType().Module).ToInt32(), EnvCatID, "ManagedMenu", 1, 2, 1, 2, commandIDs.Length, commandNames, commandIDs);
               
                if (bFirstTime) 
                {
                    SolidEdgeFramework.Environment env = (SolidEdgeFramework.Environment)pEnvironmentDispatch;
                    env.CommandBars.Add("ManagedMenu",SolidEdgeFramework.SeBarPosition.seBarTop); 
                    m_addin.AddCommandBarButton(EnvCatID, "ManagedMenu", 101);
                    m_addin.AddCommandBarButton(EnvCatID, "ManagedMenu", 102);                    
                }

                
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
...

 

Best regards.

 

Posted by: joseph polk
Post date: 5/6/2012 2:17:10 PM