Es macht keinen Spaß Scripte zu testen… Immer wieder entladen, laden… die Fehlersuche wird somit noch schwieriger.
Ich habe lange überlegt, wie hier der Workflow optimiert werden kann.
Natürlich mit einem Script :)
Mit diesem Script, welches in EPLAN geladen werden muss, können verschiedene andere Scripte automatisch aus Visual Studio heraus in EPLAN getestet werden.
Der Ablauf ist wie folgt:
- ScriptTest.cs in EPLAN laden
- Visual Studio Projekt Startoptionen einstellen
- Parameter angeben
In Visual Studio sehen die Startoptionen wie folgt aus:
C:\Program Files (x86)\EPLAN\Platform\2.4.4\Bin\EPLAN.exe
/Variant:"Electric P8" ScriptTest /parameter:'' /execute:"true" /scriptPath:"C:\Test\Script\Test.cs"
Leere Parameter müssen auch mit angegeben werden.
Hinweis für Nutzer von Visual Studio Express: Dort gibt es den Einstellungsdialog für Startoptionen nicht. Ein Workaround ist hier beschrieben.
Freu mich sehr über die Arbeitserleichterung… und darüber dass ich ein Einhorn bzw. Drache sein kann!
using System; using System.Windows.Forms; using Eplan.EplApi.ApplicationFramework; using Eplan.EplApi.Scripting; using System.IO; namespace ibKastl.Scripts.Test { class ScriptTest { /// <summary> /// Start Visual Studio with the given Script /// </summary> /// <param name="scriptPath">Full Path to .cs or .vb File</param> /// <param name="parameter">Parameters for the Action</param> /// <param name="execute">Excute after EPLAN started</param> [DeclareAction("ScriptTest")] public void Action(string scriptPath, string parameter, string execute) { // Check file if (!File.Exists(scriptPath)) { MessageBox.Show("Scriptdatei wurde nicht gefunden:" + Environment.NewLine + scriptPath + Environment.NewLine + "Das Script wurde nicht geladen.", "Warnung", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { string actionName = Path.GetFileNameWithoutExtension(scriptPath); CommandLineInterpreter commandLineInterpreter = new CommandLineInterpreter(); // Unload if Action exists ActionCallingContext actionCallingContextUnregister = new ActionCallingContext(); actionCallingContextUnregister.AddParameter("DontShowErrorMessage", "1"); actionCallingContextUnregister.AddParameter("ScriptFile", scriptPath); commandLineInterpreter.Execute("UnregisterScript", actionCallingContextUnregister); // Load Script ActionCallingContext actionCallingContextRegister = new ActionCallingContext(); actionCallingContextRegister.AddParameter("ScriptFile", scriptPath); commandLineInterpreter.Execute("RegisterScript", actionCallingContextRegister); // Execute if (execute.ToLower().Equals("true")) { if (!string.IsNullOrEmpty(parameter)) { commandLineInterpreter.Execute(actionName + " " + parameter); } else { commandLineInterpreter.Execute(actionName); } } } } } }
Da erlaube ich mir mal zu sagen: Du verdammtes Genie! Tausend Dank!!!!
I’ve tried this idea and works great for the actions, but I can’t find solution If I want to declare a event.
In this case, I’ve no idea hot to modify the TestScript for loading my script.
You can also send events: https://www.eplan.help/en-US/Infoportal/content/api/2024/Eplan.EplApi.AFu~Eplan.EplApi.ApplicationFramework.EventManager~Send.html
I am not able to find below Libraries in E-plan Bin File except all other libraries are availble Could someone please suggest how to add
Eplan.EplApi.ApplicationFramework.dll
Eplan.EplApi.DataModel.dll
Eplan.EplApi.Scripting.dll
The DLLs are in the Platform/Bin folder und program files.