Eplan API 初始化


Eplan支持的开发方式一共有3种

  1. 脚本
  2. dll文件形式
  3. exe离线程式形式

虽然eplan二次开发也支持vb语言,但这里只讨论c#

脚本(script)

Eplan脚本支持的功能有限,有限的原因在于其支持的程序集有限

c#中的

  • System;
  • System.XML;
  • System.Drawing;
  • System.Windows.Forms

Epaln API中的

  • Namespace Eplan.EplApi.Base
  • Namespace Eplan.EplApi.ApplicationFramework
  • Namespace Eplan.EplApi.Scripting
  • Namespace Eplan.EplApi.Gui
  • NameSpace Eplan.EplApi.Scripting

所以现在基本使用第二种方式来代替,这里只做简单的说明。

脚本分为两种,执行和加载

执行

以Start标注,将写好的s文件保存。在【工具脚本执行】

1 using Eplan.EplApi.Base; 2 using Eplan.EplApi.Scripting; 3 4 namespace EplanDemo.Script 5 14 } 15 }

加载

或者将其标注为 事件,动作,菜单加载项,在【工具脚本加载】

1   public class SimpleEventHandler 2 9 } 10 public class RegisterScriptMenu 11 18 19 [DeclareMenu] 20 public void MenuFunction() 21 25 } 26 public class SimpleScriptAction 27 34 }

程序集(.dll)

dll文件对编译生成的名称有要求,名称的命名规范为<公司名称>.EplAddin. <NameOfTheProject>.dll.

为了减少不必要的其他bug的出现,推荐使用 framework4.7.2,输出的dll文件为64位。

编译完成之后打开epaln软件 选择【工具API插件加载dll所在目录】

ps:dll文件重新编译之后,需要重新卸载之后加载,因为eplan对dll文件的引入采用的是复制dll文件到指定目录,防止在读取dll文件的时候,文件被修改暂用,对于引用的dll文件的其他依赖dll则会在dll的目录中查找。

这里简单做一个加载的菜单项

1 using System; 2 using Systemollections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.Threading.Tasks; 6 using Eplan.EplApi.ApplicationFramework; 7 using Eplan.EplApi.Gui; 8 9 namespace EplanDemo 10 20 21 public bool OnExit() 22 25 26 public bool OnInit() 27 30 31 32 public bool OnInitGui() 33 37 38 public bool OnRegister(ref bool bLoadOnStart) 39 43 44 public bool OnUnregister() 45 48 49 50 public void Init1() 51 61 } 62 }

脱机程式

脱机程式为.exe可执行文件,基本上在windows上分为两种 Winfr,Wpf

其初始赖于四个dll文件,引入其中。但程序想运行起来还是需要依赖于其他的dll。 在这里有两种处理方式。

  1. 将生成的程式的目录放置在程式的安装目录中 <eplan main path>\Platform\ <version>\Bin folder,
  2. 指定dll文件的形式。
    1. 在程式运行的时候通过反射动态加载未找到的dll文件
    2. 在程式加载的时候引入所有的dll文件

这里只讨论第二种的一二两种方式。

引入dll文件

winfr在programs中,wpf则在app.xamls中引入

动态加载
1 static class Program 2 19 20 static Assembly MyResolveEventHandler(object sender, ResolveEventArgs args) 21 27 } 28 // wpf 29 public partial class App : Application 30 39 40 static System.Reflection.Assembly MyResolveEventHandler(object sender, ResolveEventArgs args) 41 50 else 51 55 } 56 }
引入全部
1 public partial class App : Application 2 7 8 9 static void LoadEplanDll() 10 21 } 22 } 23 }

初始化

1 private void Window_Loaded(object sender, RoutedEventArgs e) 2



上一篇:Qt 使用Qss设置QPushButton图标和显示文本的位置

下一篇:联想屏幕亮度调节失灵(已解决)


EPLAN
Copyright © 2002-2019 k262电脑网 www.k262.cn 皖ICP备2020016292号
温馨提示:部分文章图片数据来源与网络,仅供参考!版权归原作者所有,如有侵权请联系删除!QQ:251442993 热门搜索 网站地图