📜 ⬆️ ⬇️

Expansion of EPLAN functionality. Creating a simple Add-Ina in C #

Expanding EPLAN functionality with Add-In on C #


EPLAN is a platform for end-to-end design, covering the following industries: electrical engineering, instrumentation and automation, hydraulics / pneumatics and mechanics (design of cabinets and harnesses). Due to the open architecture and standard integration modules, EPLAN can be cost-effectively integrated with a wide range of third-party solutions: mechanical design systems, ERP and PDM systems, building design systems, industrial plants and ships.

EPLAN application

• Automotive
• Mechanical Engineering
• Metallurgy
• Chemical and pharmaceutical industry
• Food industry
• Mining of oil and gas
• Pipeline transportation
• Oil and gas processing
• Heat and power generation
• Transmission and distribution of electricity
• Railway transport
• Water supply and sanitation
• Machine tool industry
• Light industry
• Building Automation

Main modules of the platform

• EPLAN Electric P8 - Modular and scalable solution for electrical design, automatic creation of design and working documentation.
• EPLAN Fluid - Software for designing pneumatic / hydraulic automation, lubrication and cooling systems and automatic creation of relevant design and working documentation.
• EPLAN ProPanel - 3D design of electrical cabinets with the transfer of data in production. Virtual three-dimensional modeling, the creation of two-and three-dimensional drawings, a three-dimensional image of wired and routing schemes, the presence of templates for the operation of drilling equipment and integration with CNC machines
• EPLAN PrePlanning - software for preliminary (draft) design of objects and generation of project documentation.
• EPLAN Engineering Center - Solution for functional design. In this module, the user will touch the project’s boundary parameters, and the design itself is carried out automatically by the system according to certain rules.

About the expansion of the functional

EPLAN is a flexible platform that allows you to extend functionality with scripts and add-ins. Consider only add-ins, since scripts (scripts) give much less freedom of action.
')
An add-in is an add-on that complements and extends the basic functionality offered by EPLAN. An add-in is created using the EPLAN API, which, in turn, uses dotNET and supports 3 programming languages: Visual Basic, C ++ and C #. The procedure for creating Add-In is the same for all the above languages. Information on the EPLAN API is in the EPLAN API-Support (in * .chm format), supplied with the documentation.

Add-Ina creation process

Consider directly the process of creating Add-Inov.

1. To begin with, as the dotNET environment is used, we create the Class Library project in MS Visual Studio.
2. Next, we connect the EPLAN API library to the project.



3. We write the initialization code Add-In
To register and initialize the Add-Ina, our class must inherit the IEplAddIn interface (for more, see EPLAN API-Support). Create a menu item in the EPLAN Main Menu and add one action (Action) to it.

using Eplan.EplApi.ApplicationFramework; using Eplan.EplApi.Gui; namespace Test { public class AddInModule:IEplAddIn { public bool OnRegister(ref bool bLoadOnStart) { bLoadOnStart = true; return true; } public bool OnUnregister() { return true; } public bool OnInit() { return true; } public bool OnInitGui() { Menu OurMenu = new Menu(); OurMenu.AddMainMenu("", Menu.MainMenuName.eMainMenuUtilities, "  ", "ActionTest", " ,    ", 1); return true; } public bool OnExit() { return true; } } } 

The OnRegister and OnUnregister methods are called once, when the Add-Ina is first connected and deleted, respectively.
The OnExit method is called when you close EPLANa.
The OnInit method is called when loading EPLANa to initialize the Add-Ina.
The OnInitGui method is called when loading EPLANa to initialize the Add-Ina and the user interface.

4. Write the action code (Action), which will be in our menu. An Action must inherit the IEplAction interface (more details in EPLAN API-Support).

 using System; using System.Windows.Forms; using Eplan.EplApi.ApplicationFramework; using Eplan.EplApi.DataModel; using Eplan.EplApi.HEServices; namespace Test.Action_test { public class Action_Test:IEplAction { public bool OnRegister(ref string Name, ref int Ordinal) { Name = "ActionTest"; Ordinal = 20; return true; } public bool Execute(ActionCallingContext oActionCallingContext) { SelectionSet Set = new SelectionSet(); Project CurrentProject = Set.GetCurrentProject(true); string ProjectName = CurrentProject.ProjectName; string ProjectCompanyName = CurrentProject.Properties.PROJ_COMPANYNAME; DateTime ProjectCreationDate = CurrentProject.Properties.PROJ_CREATIONDATE; MessageBox.Show(" : " + ProjectName + "\n" + " : " + ProjectCompanyName + "\n" + "  : " + ProjectCreationDate.ToShortDateString()); return true; } public void GetActionProperties(ref ActionProperties actionProperties) { } } } 

The OnRegister method registers our Action with the specified name.
The Execute method is executed when calling Actiona from the EPLAN platform. In this case, the Execute method selects the current project, reads three fields from it, namely, the project name, company name and creation date, and then displays them in the MessageBox .
The GetActionProperties method returns the description of our Actiona (for documentation only).

5. The name of the compiled DLL must comply with the following rule:

Eplan.EplAddIn.XXXX.dll
where XXXX is the name of your Add-Ina

Add-in connection

To the Add-In platform is connected as follows:

1. We carry out "Service programs"
- “API-AddIns ...”



2. Click on the button "Download"



3. In the window that opens, select the Add-In and click "Open"



4. Click on the "OK" button. The add-in is loaded and ready to go.


When the Add-In is loaded, the “Test” menu item is initialized, revealing which we see our Action (Action), described in Action_Test.

Let's look at the result of the Add-Ina:



Click on the menu item "Test" - "Information on the project"



The EPLAN platform provides great basic functionality. However, sometimes actions are required that are not included in it. In the simplest cases, you can create and connect scripts (scripts), but if you need deep access to data, you need to use the API, create and use Add-In.

useful links

1. EPLAN in Russia
2. Forum ACS TP

Source: https://habr.com/ru/post/271671/


All Articles