Batch Pole Operations in Scripts and Plugins

Home » Plugin development » Batch Pole Operations in Scripts and Plugins
Plugin development, Scripting No Comments

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:

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Windows.Forms;
  5. using PPL_Lib;
  6. public class Script
  7. {
  8.     PPLMain cPPLMain = null;
  9.     public void Execute(PPLMain pPPLMain)
  10.     {
  11.         cPPLMain = pPPLMain;
  12.         using (BatchPoleHelper helper = new BatchPoleHelper(cPPLMain, "Batch Demo"))
  13.         {
  14.             helper.PoleReadyForBatchProcessing += helper_PoleReadyForBatchProcessing;
  15.             cPPLMain.SetToolFormPosition(helper);
  16.             helper.ShowDialog();
  17.         }
  18.     }
  20.     void helper_PoleReadyForBatchProcessing(PPLPole pPole)
  21.     {
  22.         MessageBox.Show(pPole.DisplayedName(PPLElement.DISPLAY_NAME_MODE.INVENTORY));
  23.     }
  24. }

The important point to notice is that there are two basic steps.

  1. Instantiate a BatchPoleHelper and show it
  2. 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.