Getting Started with The Eclipse Scripting API
To get quickly started with the Eclipse Scripting API, you can:
- Copy the code shown below to a file.
- Save the file with a .cs extension on the hard disk of your workstation.
using System;
using System.Text;
using System.Windows;
using VMS.TPS.Common.Model.API;
namespace VMS.TPS
{
class Script
{
public Script()
{
}
public void Execute(ScriptContext context)
{
if (context.Patient != null)
{
MessageBox.Show("Patient id is " + context.Patient.Id);
}
else
{
MessageBox.Show("No patient selected");
}
}
}
}
Figure 11 Sample Script Code
- In Eclipse, select Tools > Scripts.
- Select the Directory: [path_to_your_own_scripts] option.
- To locate the script that you created, click Change Directory.
- In the Scripts dialog box, select the script from the list and click Run. The script displays a message box which contains the ID of the patient that is open in Eclipse.
Using Example Scripts
The Eclipse Scripting API includes example scripts for a few of the supported script types. You can first copy the example scripts by using the Script Wizard, and then compile them by using Visual Studio. If you do not have Visual Studio available, you can compile the examples with the MSBuild program, which is included in the Microsoft .NET framework.
Copy Example Scripts
To copy the example scripts to your own location:
- From the Start menu, select Varian > Eclipse Scripting API > Eclipse Script Wizard.
- Click the Copy Example Scripts tab.
- To select a location for copying the example scripts, click Browse.
- Click Copy. The example scripts are copied to the specified location.
Compile Example Scripts
To compile the examples by using Visual Studio:
- Open the Visual Studio project files.
- Compile the examples.
After this, you can launch the example scripts. If you do not have Visual Studio available, you can compile the examples with the MSBuild program, which is included in the Microsoft .NET framework and the Microsoft Build Tools package. To compile the examples by using MSBuild:
- In the file browser, go to the directory where you copied the example scripts.
- Open Command Prompt.
- Enter the following information on the command line:
- The path to the directory where MSBuild.exe is located.
- The name of the project file.
- Platform specification for x64.
For example:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe Example_DVH.csproj /p:Platform=x64
- To compile the example, press ENTER.