top of page
Search

Show a progress bar with Cancel in Eplan Electric P8 scripts (C#)

Writer: Justin Walz
Justin Walz
Nov 12
3 min read

When an Eplan Electric P8 script works through a long list, people want to see that something is happening, and to be able to stop it. Eplan has its own progress window, and a script can use it with a few lines of C#. A progress window is the small window with a bar that fills as work gets done.

You would use this for any script that loops over many pages, devices or files.

Screenshot of the example dialog

What you will build

A script that works through 20 pretend items in two parts, shows Eplan's progress window with a Cancel button, and ends with a message that says whether it finished, was cancelled, or hit an error.

What you will learn

  • How to create and show Eplan's Progress window

  • Splitting a long job into parts, and why the parts add up to 100%

  • Counting steps so the bar moves smoothly

  • Letting the user cancel, and checking for it in your loop

  • try, catch and finally: why the progress must always be ended, even after an error

Before you start

  • Eplan Electric P8 with scripting available (the example was run in 2026.0.3)

  • No C# experience required, though basic programming ideas help; the example file explains new ideas in comments

How it works

The job is split into two parts (sections of the work): preparing (5 items, the first 30% of the bar) and processing (15 items, the remaining 70%). A small helper method, RunPart, runs one part and checks after every item whether the user pressed Cancel. The pretend work is a short pause per item, so replace that one line with your own work.

The progress is always ended in a finally block. A finally block runs whether the work succeeded or failed, so the progress window is closed even when something goes wrong.

Common mistakes

  • Not ending the progress when an error happens, which can leave the window open

  • Setting the number of steps before that part (section) of the job has begun, so the steps are ignored

  • Showing your own message box while the progress window is still open, where it can hide behind it

Try it yourself

Ideas to extend

  • Challenge: change the two parts to 3 items and 7 items and watch how the bar moves

  • Replace the pause with a real loop over the pages of a project

  • Show how many items were processed in the final message

Key takeaways

  • Give long jobs a progress window with Cancel

  • Always end the progress in a finally block

  • Show your own messages after the progress window has closed

Community spotlight

  • Who or what: Eplan's official How To Eplan YouTube channel: https://www.youtube.com/@HowToEplan

  • Why it is worth a look: Eplan's own channel with short tutorials and feature demonstrations, handy for seeing how features look in everyday use.

  • Good to know: In English, and suited to all levels.

Maintained by Justin Walz, Walz Engineering. Questions and ideas for future examples are always welcome, and if you would like help with a script of your own, feel free to get in touch.

 
 
 

Comments


bottom of page