Varian ESAPI Workshop: Brazilian Medical Physics Conference (CBFM)

João Castelo
2 min readJun 23, 2022


Hello! Been gone for some time, but back for business! 😁😁

In June 8 (2022), Anselmo Mancini and I presented the Varian Eclipse Scripting WorkShop at the the Brazilian Medical Physics Conference (CBFM).

It was the first time since 2019 we’ve had an “offline” conference. It was a 4 hour long event, and we had 30–40 people attending!

First part was one hour lecture of C# and ESAPI basics, we jumped into a very similar example as presented in my 5 steps to start ESAPI scripting post.

We create a class called Patient, then we read from a csv file and we create a patients list from it. Then we filter the urgent patients from the list and print their info.

The second part was live coding two binary plugins with WPF User Interfaces:

Simple Plan Check tool:

Code is here:

User Interface

In the main Script file, we create a class called Check, which has 3 properties, Title, Result and Comment.

This Class has a constructor with two default arguments, an empty comment and an OK Result. When you create a check with the Title “Check whatever”, you’ll have to code the business logic and change the Result and Comment on the fly.

A MainWindow.xaml is created to hold a List View of CheckScreen.xaml, that displays the Check’s Title and Result, changes it’s color based on the test result, and when you click on the check, it pops the Comment.

Create Optimization Structures:

Code is here:

In this plugin, the overlapping region between the OARs and the PTVs sum + margin is checked and it crops the OARs with the margin chose by the user in a WPF window.

Since it is a showcase code, it does not handle operations between Structures with High Resolution and Default.

User interface

Hope you enjoy!

Thanks to Anselmo and Varian for this great experience, I hope we can repeat it in the future!

Thanks to Jonas for reviewing!



João Castelo

Radiation Therapy Medical Physicist and Programmer