It is possible to debug Eplan scripts. To do this successfully, there are a few things to keep in mind.
First, you need to enable script debugging in the appropriate bool setting. The setting is called USER.EplanEplApiScriptLog.DebugScripts. Then, you must prepare your script by adding a manual breakpoint to it. You can do this using System.Diagnostics.Debugger.Break(). For further information, please refer to the corresponding .NET documentation. Below is an example of a simple script that can be debugged:
Make sure that manual breakpoints and other debugger diagnostics are only hit when script debugging is enabled and a debugger is attached. Otherwise, this may lead to errors. If you want to run your script without script debugging, you can temporarily remove them from your script. However, a better approach is to wrap manual breakpoints and other debugger diagnostics using the if (Debugger.IsAttached) statement, for example. Please refer to the example above.
Once the prerequisites have been met, follow these steps:
1. Open your script in an integrated development environment (IDE) with a built-in debugger.
2. Open Eplan Electric P8.
3. Attach the debugger to the Eplan process and make sure to use .NET Core / .NET 5+ as debugger type. If you are using Visual Studio, do this via Debug > Attach to Process… > Eplan.exe. Before you click Attach, set the Code type to "Managed (.NET Core, .NET 5+)".
4. Now load or execute your script in Eplan Electric P8 via File > Extras > Interfaces > Scripts > Load / Run. This step will automatically create a copy of your script named Debug_<YourScriptName> and store this copy in the local temp folder. The script copy will be opended in your IDE and the debugging will take place in this copy.
5. You can then set / remove additional automatic breakpoints in the script copy in your IDE just as you normally would.
For further information, please read the following chapters: