API and Scripting Documentation
Introduction
Scripting functionality is available in SolarFarmer, albeit slightly limited at the moment. This allows you to write scripts in the C# programming language that update parameters in the workbook and execute certain functionality, such as running calculations.
Script Editor
To launch the script editor click on the 'Script Editor' button in the Quick Access Toolbar in the left of the application's title bar (highlighted in red below):
The Script Editor allows you to write and run simple scripts. You can create multiple scripts that are saved in the current workbook.
There isn't a comprehensive reference document yet for what is available in scripting. You can discover what is available by using the built-in intellisense functionality. When you type a variable and press the '.' keyboard key, the list of available properties shows in a popup menu. Choose one of the available properties (with the mouse or arrow keyboard keys) and press Return to add that property.
'Workbook' for accessing the workbook settings
There is an object called Workbook (of type Workbook
) that you can use to access the properties of the current workbook. Use the intellisense to navigate the various properties and sub-properties.
'Toolbox' for accessing the calculation toolbox
There is an object called Toolbox (of type Toolbox
) that you can use to access various functions for working with the workbook. Most notably ExecuteEnergyCalculation
.
Use Toolbox.Log()
to write text to the output panel. Useful for viewing the values of variables.
Scripting in Future
The scripting functionality will be extended in future, with more comprehensive coverage of the workbook parameters and a reference guide. Please email the SolarFarmer support email if you have specific requests or need more guidance.