Templates
Template files saved interactively from HEC-DSSVue may be applied to plots via
scripting. When saving a template interactively from the plot window via the “Save
Template…” entry on the “File” menu, HEC-DSSVue:
The applyTemplate(string filename) G2dDialog method requires the actual file name for
the template file. To apply a template saved in the default directory, the complete
template file name must be re-created as demonstrated in the example below.
|
Example: Applying Template Saved in Default Directory
import os # for getenv() & sep from hec.script import * # for Plot class from hec.heclib.dss import * # for DSS class thePlot = Plot.newPlot() # create a Plot dssFile = HecDss.open(“C:/mydb.dss”) # open the DSS file flow = dssFile.get(“/BASIN/LOC/FLOW/01NOV2002/1HOUR/OBS/”) # read a data set thePlot.addData(flow) # add the data set thePlot.showPlot() # show the plot templateName = “myTemplate” # template base name templateFileName = \ # re-create the file name os.getenv(“userprofile”) \ + os.sep \ + “My Documents” \ + os.sep \ + templateName \ + “.template” thePlot.applyTemplate(templateFileName) # apply the template |