使用C#语言,如何实现EPLAN二次开发 Api插件及菜单展示

上期我们谈谈了谈EPLAN电气制图二次开发,制图软件EPLAN的安装和破解,今天我们来说说使用C#语言,如何实现Api插件及菜单,今天它来了!!!

关于项目环境的搭建请参考:https://blog.csdn.net/Laity07/article/details/109215518

下面我们一起来看看

我们就以我写的一个例子来看

首先建立一个这样的类,

复制代码
using Eplan.EplApi.ApplicationFramework;
using Eplan.EplApi.DataModel;
using Eplan.EplApi.HEServices;
using Frm_Eplan_EplanApi;
using Frm_Eplan_EplanApi.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Forms;

namespace Eplan_EplanApi
{
    public class MyAction : IEplAction, IEplActionEnable
    {
        //public delegate //PathFileAcross pathFile;
        public bool Execute(ActionCallingContext ctx)
        {
            
            return true;

        }

        public bool OnRegister(ref string Name, ref int Ordinal)
        {
            Name = "功能配置";
            Ordinal = 20;
            return true;
        }

        public void GetActionProperties(ref ActionProperties actionProperties)
        {
            // actionProperties.Description = "Action test with parameters."; 
        }

        public bool Enabled(string strActionName, ActionCallingContext actionContext)
        { 
            return true;
        }
    }
}
MyAction
复制代码

第二步,我们再建一个这样的类

复制代码
using Eplan.EplApi.Base;
using Eplan.EplApi.Gui;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ContextMenu = System.Windows.Forms.ContextMenu;

namespace Eplan_EplanApi
{
    public class AddInModule : Eplan.EplApi.ApplicationFramework.IEplAddIn
    {
        public bool OnExit()
        {
            return true;
        }
        public bool OnInit()
        {
            return true;
        }

        public bool OnInitGui()
        {
            //菜单栏菜单
            Eplan.EplApi.Gui.Menu oMenu = new Eplan.EplApi.Gui.Menu();
          //一级菜单
            uint num1 = oMenu.AddMainMenu("Test", Eplan.EplApi.Gui.Menu.MainMenuName.eMainMenuHelp, "项目配置", "MyAction", "项目配置", 0);
            
            
            #region 单功能配置显示二级菜单
              //我们在一级菜单的基础上新增新的菜单,并在二级菜单显示新的子菜单
           //此处的“功能配置”为二级菜单名称
            uint menu3 = oMenu.AddPopupMenuItem("功能配置", "此处都为你二级菜单下子菜单的Action类(例如:电源进线)", "电源进线", "电源进线", num1, 1, false, false);
            oMenu.AddMenuItem("控制电源", "此处都为你二级菜单下子菜单的Action类(例如:控制电源)", "控制电源", menu3, 1, true, false); 
            #endregion 
            return true;
        }

        public bool OnRegister(ref bool bLoadOnStart)
        {
            bLoadOnStart = true;
            return true;
        }

        public bool OnUnregister()
        {
            return true;
        }
    }
}
AddInModule
复制代码

最后一定要把  右击-打开项目属性的程序集名称修改为这样的格式 EPLAN.EplAddin.MyAddIn

 

 

这些都设置好了,我们下面看看将生成的.dll的程序集加载到EPLAN中后的效果吧

 

 

最后这个东西吧,还是要好好阅读API文档,看懂了就明白了。

https://blog.csdn.net/Laity07/article/details/109236645

 

Nothing that has meaning is easy.
凡是有意义的事都不简单。

 

posted on   独行者*  阅读(2806)  评论(0编辑  收藏  举报

编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示