Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.

Creating a Solid Edge AddIn

Jason Newell edited this page Aug 17, 2015 · 1 revision

The SolidEdgeCommunity.AddIn namespace contains community developed classes that make developing Solid Edge AddIns much easier than normal. The Solid Edge AddIn architecture is COM based and does not support many .NET features we are accustomed to.

Note: The following examples are in C# but the process is the same for Visual Basic.

namespace AddInDemo
{
    [ComVisible(true)]
    [Guid("BF1C1BB8-75EE-444A-8DCE-0F1521D0764B")] // Must be unique!
    [ProgId("SolidEdgeCommunity.AddInDemo.MyAddIn")] // Must be unique!
    public class MyAddIn : SolidEdgeCommunity.AddIn.SolidEdgeAddIn
    {
        /// <summary>
        /// Called when the addin is first loaded by Solid Edge.
        /// </summary>
        public override void OnConnection(
            SolidEdgeFramework.Application application,
            SolidEdgeFramework.SeConnectMode ConnectMode,
            SolidEdgeFramework.AddIn AddInInstance)
        {
            // If you makes changes to your ribbon, be sure to increment the GuiVersion or your ribbon
            // will not initialize properly.
            AddInEx.GuiVersion = 1;
        }

        /// <summary>
        /// Called when the addin first connects to a new Solid Edge environment.
        /// </summary>
        public override void OnConnectToEnvironment(
            SolidEdgeFramework.Environment environment,
            bool firstTime)
        {
        }

        /// <summary>
        /// Called when the addin is about to be unloaded by Solid Edge.
        /// </summary>
        public override void OnDisconnection(
            SolidEdgeFramework.SeDisconnectMode DisconnectMode)
        {
        }
        
        /// <summary>
        /// Called when regasm.exe is executed against the assembly.
        /// </summary>
        [ComRegisterFunction]
        public static void OnRegister(Type t)
        {
            string title = "SolidEdge.Community.AddInDemo.MyAddIn";
            string summary = "Solid Edge Addin in .NET 4.0.";
            var enabled = true; // You have the option to register the addin in a disabled state.

            // List of environments that your addin supports.
            Guid[] environments = {
                                      SolidEdgeSDK.EnvironmentCategories.Application,
                                      SolidEdgeSDK.EnvironmentCategories.AllDocumentEnvrionments
                                    };

            try
            {
                MyAddIn.Register(t, title, summary, enabled, environments);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.StackTrace, ex.Message);
            }
        }

        /// <summary>
        /// Called when regasm.exe /u is executed against the assembly.
        /// </summary>
        [ComUnregisterFunction]
        public static void OnUnregister(Type t)
        {
            MyAddIn.Unregister(t);
        }
    }
}
  • Build your solution.
  • From the Package Manager Console window, execute Register-SolidEdgeAddIn.
  • Set breakpoints on OnConnection, OnConnectToEnvironment & OnDisconnection.
  • Configure your project to start Solid Edge during debugging.
  • Start debugging your project and you will hit the breakpoints.
Clone this wiki locally