When creating O-Calc scripts and plugins it is often the case that the developer / user would like to be able to perform operations on a large number of poles in a batch operation, perhaps as an un-attended operation. The O-Calc scripting and plugins API provides a convenient way to allow this to be done while hiding the considerable complexity of managing the multiple calculation threads and processing various pole versions and LoadCases.
In the following simple “hello world” type example is presented a script that opens all of the poles selected and displays the pole number in a message box:
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Windows.Forms;
- using PPL_Lib;
- public class Script
- PPLMain cPPLMain = null;
- public void Execute(PPLMain pPPLMain)
- cPPLMain = pPPLMain;
- using (BatchPoleHelper helper = new BatchPoleHelper(cPPLMain, "Batch Demo"))
- helper.PoleReadyForBatchProcessing += helper_PoleReadyForBatchProcessing;
- void helper_PoleReadyForBatchProcessing(PPLPole pPole)
The important point to notice is that there are two basic steps.
- Instantiate a BatchPoleHelper and show it
- Catch the PoleReadyForBatchProcessing event
The PoleReadyForBatchProcessing event will be fired every time that a pole has been loaded, the correct LoadCase has been selected, and that the pole load calculation process has been successfully completed.