Ich hatte ja hier mal einen Eventlogger geschrieben. Diesen habe ich jetzt erweitert. Es werden folgende Eigenschaften gespeichert:
- Uhrzeit
- Eventname
- Eventparameter (falls vorhanden)
Es ist auch eine Blacklist vorhanden, da diese Events immer gefeuert werden bzw. wenn EPLAN im Idle-Modus ist.
using System;
using System.Collections.Generic;
using System.IO;
using Eplan.EplApi.ApplicationFramework;
using Eplan.EplApi.Scripting;
using EventHandler = Eplan.EplApi.ApplicationFramework.EventHandler;
public class EventLogger
{
EventHandler eventHandler = new EventHandler();
[DeclareRegister]
public void Register()
{
eventHandler.SetEvent("*");
EventHandlerNameFunction eventHandlerNameFunction = Event;
eventHandler.EplanNameEvent += eventHandlerNameFunction;
}
[DeclareUnregister]
public void UnRegister()
{
eventHandler.Dispose();
}
private void Event(IEventParameter eventParameter, string eventName)
{
// Check Blacklist
List<string> blackList = new List<string>
{
"onIdle.Bool.App",
"onLastIdle.Bool.App",
"onTimer.UInt.App"
};
if (blackList.Contains(eventName))
{
return;
}
// Get Parameter
string parameter;
try
{
EventParameterString eventParameterString = new EventParameterString(eventParameter);
parameter = eventParameterString.String;
}
catch
{
parameter = string.Empty;
}
// Write log
FileInfo fileInfo = new FileInfo(@"C:\Test\Events.txt");
using (StreamWriter streamWriter = fileInfo.AppendText())
{
string line = string.Format("{1}{0}{2}{0}{3}",
"\t",
DateTime.Now.ToString("HH:mm:ss"),
eventName,
parameter);
streamWriter.WriteLine(line);
}
}
}

Hello.
You’re doing a good job with EPLAN. I started to write simple programs myself, but I came across a problem. Maybe you will be able to help me. I want read (for example) “Zusatzfeld [1] <11901 1>” from selected page and save value to TXT file. Saving to TXT is easy but how to declare the variable responsible for “Zusatzfeld [1] <11901 1>”. Thanks for any replay.
Create a label scheme and replace the value of the property in the xml file. Then import the scheme and execute label. Here is an example for project properties.
Hello, once again. I have one more question. Is there a possibility to read (using API of course) value from text field in specific coordinates (X, Y) ? Maybe using “PointD” (we can create using PoinD but do we can get value in this same way) ? I will be grateful for your response. Peace.
You can use the API to check the location of a placement. If its the location you search for, you have your text.
Hello. I’m sorry to bother you, but from i can see you are the best in API Eplan. Firstly i want to say ‘thank you’ for your support. Maybe also this time you be able to help me.
SelectionSet set = new SelectionSet();
Project oProj = set.GetCurrentProject(true);
int oDim = oProj.Pages.Length;
string[] oArray = new string[oDim];
oArray = oProj.Pages; // Project’s property which return array of Pages placed in project.
I cant assign oProj.Pages to my array, i making something wrong for sure. But i cant figure out what. This is my first steps in C#. Some tip would be great. Thank again. Take care.
Thanks.
Your array is of type String… So you could not assign a array of type Page to it.
you said that i need check location to find if there is text, and i make something like this:
Project oProject = new ProjectManager().GetCurrentProjectWithDialog(); Page oPage = (Page)set.GetSelectedPages().GetValue(0); DMObjectsFinder oFinder = new DMObjectsFinder(oProject); Placement[] oObject = oFinder.GetPlacements(null); string myText; int oObjectCount = oObject.Length; for (int a = 0; a < oObjectCount; a++) { if ((oObject[a].Location.X) == 200 && (oObject[a].Location.Y) == 164) { myText = oObject[a].Name; } }…but it comes out that i can’t find “text object”. Do you have some tips for me ? Thanks.
oh i forgot about one line, should be included
Please write me an Email, this is not topic of EventLogger