172 lines
5.3 KiB
HTML
172 lines
5.3 KiB
HTML
|
<html>
|
||
|
<title>Smart Script Class - Calling Smart Tools and Procedures</title>
|
||
|
<body>
|
||
|
|
||
|
<h1><a name="Calls"></a>Calling Smart Tools and Procedures</h1>
|
||
|
<br>
|
||
|
<a href="#callArgs">Calling Smart Tools and
|
||
|
Procedures
|
||
|
Arguments</a>
|
||
|
<br>
|
||
|
<a href="#callSmartTool">callSmartTool</a>
|
||
|
<br>
|
||
|
<a href="#callProcedure">callProcedure</a>
|
||
|
<!-- Leave this comment for formatting purposes -->
|
||
|
<hr width="100%">
|
||
|
|
||
|
|
||
|
<h2>
|
||
|
<a name="callArgs"></a>Calling Smart Tools and Procedures Arguments</h2>
|
||
|
## editArea : ReferenceData
|
||
|
or None
|
||
|
<br>
|
||
|
## (See
|
||
|
getEditArea)
|
||
|
<br>
|
||
|
## If
|
||
|
you specify None, the system will supply
|
||
|
<br>
|
||
|
## the
|
||
|
active edit area from the GFE or from
|
||
|
<br>
|
||
|
## the
|
||
|
editArea argument for runProcedure.
|
||
|
<br>
|
||
|
## timeRange: TimeRange
|
||
|
or None
|
||
|
<br>
|
||
|
## (See
|
||
|
getTimeRange and createTimeRange)
|
||
|
<br>
|
||
|
## If
|
||
|
you specify None, the system will supply
|
||
|
<br>
|
||
|
## the
|
||
|
selected Time Range from the GFE or from
|
||
|
<br>
|
||
|
## the
|
||
|
timeRange argument for runProcedure.
|
||
|
<br>
|
||
|
## varDict : If you supply a varDict
|
||
|
in this call, the
|
||
|
<br>
|
||
|
##
|
||
|
variable
|
||
|
list dialog will not be displayed
|
||
|
<br>
|
||
|
## when
|
||
|
the tool is run.
|
||
|
<br>
|
||
|
## If
|
||
|
you supply a varDict from a Procedure,
|
||
|
<br>
|
||
|
## make
|
||
|
sure that the variables
|
||
|
<br>
|
||
|
## for
|
||
|
all the tools called by the procedure are
|
||
|
<br>
|
||
|
##
|
||
|
supplied
|
||
|
in your varDict.
|
||
|
<br>
|
||
|
## missingDataMode: Can be "Stop",
|
||
|
"Skip",
|
||
|
or "Create". If not
|
||
|
<br>
|
||
|
##
|
||
|
included,
|
||
|
will be set to the current GFE default.
|
||
|
<br>
|
||
|
## modal: If 0, VariableList dialogs
|
||
|
will appear with the
|
||
|
<br>
|
||
|
##
|
||
|
non-modal
|
||
|
"Run" and "Run/Dismiss" buttons.
|
||
|
<br>
|
||
|
##
|
||
|
Otherwise,
|
||
|
they will appear with the "Ok" button.
|
||
|
<br>
|
||
|
##
|
||
|
<br>
|
||
|
## These commands all return an error
|
||
|
which will be None if no
|
||
|
<br>
|
||
|
## errors
|
||
|
occurred. Otherwise, the errorType and errorInfo
|
||
|
<br>
|
||
|
## can
|
||
|
be accessed e.g. error.errorType() and error.errorInfo()
|
||
|
<br>
|
||
|
## If "noData" has been called, the
|
||
|
errorType will be "NoData" and
|
||
|
<br>
|
||
|
## can
|
||
|
be tested by the calling tool or script.
|
||
|
<h2><a name="callSmartTool"></a>callSmartTool</h2>
|
||
|
def callSmartTool(self, toolName, elementName, editArea=None,
|
||
|
timeRange=None,
|
||
|
varDict=None, editValues=1, calcArea=0, calcGrid=0, passErrors=[],
|
||
|
missingDataMode="", modal=1):
|
||
|
<br>
|
||
|
# passErrors: a list of errors
|
||
|
to ignore and pass back to the
|
||
|
<br>
|
||
|
# calling program. Some errors
|
||
|
that can be ignored are:
|
||
|
<br>
|
||
|
# NoData
|
||
|
<br>
|
||
|
#
|
||
|
NoElementToEdit
|
||
|
<br>
|
||
|
#
|
||
|
ExecuteOrClassError
|
||
|
<br>
|
||
|
#
|
||
|
LockedGridError
|
||
|
<br>
|
||
|
#
|
||
|
<br>
|
||
|
# For example:
|
||
|
<br>
|
||
|
# In the Procedure:
|
||
|
<br>
|
||
|
# error
|
||
|
= self.callSmartTool(
|
||
|
<br>
|
||
|
|
||
|
#
|
||
|
"MyTool", "MixHgt", editArea, timeRange, varDict,
|
||
|
<br>
|
||
|
|
||
|
#
|
||
|
passErrors= ["NoData"])
|
||
|
<br>
|
||
|
# if error
|
||
|
is not None:
|
||
|
<br>
|
||
|
|
||
|
#
|
||
|
print "No Data available to run tool"
|
||
|
<br>
|
||
|
#
|
||
|
<br>
|
||
|
# In the Smart Tool:
|
||
|
<br>
|
||
|
# mixHgt
|
||
|
= self.getGrids(model, "MixHgt", "SFC", timeRange)
|
||
|
<br>
|
||
|
# if
|
||
|
mixHgt
|
||
|
is None:
|
||
|
<br>
|
||
|
|
||
|
#
|
||
|
self.noData()
|
||
|
<h2><a name="callProcedure"></a>callProcedure</h2>
|
||
|
def callProcedure(self, name, editArea=None, timeRange=None,
|
||
|
varDict=None,
|
||
|
missingDataMode="Stop", modal=1):
|