Exercise outline
The goal of this exercise is to create a small script for our Volume model plugin that creates a runnable Volume model.
Create a script in the DeltaShell toolbox
Run DeltaShell and go to the "Toolbox" toolwindow.
Go to the Scripts folder and create a new script (right click on folder | Add new script) named "VolumeModelScript".
Add the following code in the opened scripting view :
# import standard scripting library from Libraries.StandardFunctions import * # import our model from DeltaShell.Plugins.VolumeModel.Models import VolumeModel # import some DeltaShell (C#) libraries from NetTopologySuite.Extensions.Features import Feature from NetTopologySuite.Extensions.Geometries import GeometryHelper # import .Net library from System import DateTime # create an instance of our model and set the name model = VolumeModel() model.Name = "My test model" # Generate Precipitation data startDate = DateTime.Now for i in range(0,100): currentDateTime = startDate.AddHours(i) model.Precipitation[currentDateTime] = i * 1.0 # convert i to double # Generate drainagebasin for i in range(0,10): newFeature = Feature() offset = i * 100 newFeature.Geometry = GeometryHelper.GetRectangle(0 + offset,0 + offset,100+ offset,100+ offset) model.Basin.Catchments.Add(newFeature) # Add model to project AddToProject(model) # Run the model RunModel(model, True) # Open a view for the model OpenView(model)