Suppose that you would like to create your own
library
methods to share among your smart tools and procedures. In this
exercise,
we will create a Utility that can be imported and accessed from any
Smart
Tool or Procedure.
- In Localization perspective under the GFE section,
on the Utility folder, select MB3-->New.
- Name your Utility and select OK.
- A Python window will appear. Enter some utility method
within the
utility class. For example, you could simply copy the
"convertFtToM"
method from the SmartScript module. To follow the naming
conventions, precede the name of your method with an
underscore.
For example, _convertFtToM.
- Now, modify your Smart Tool from the previous Exercise to call
this method.
To do this, you must do several things:
- First, at the beginning of your Smart Tool, insert the
statement:
import MyUtility
where
"MyUtility"
is the name of your Utility.
- Create an instance of your Utility as follows:
class Tool (SmartScript.SmartScript):
def __init__(self, dbss):
self._dbss = dbss
SmartScript.SmartScript.__init__(self, dbss)
def preProcessTool(self):
self._myUtility = MyUtility.MyUtility(self._dbss, self.eaMgr())
- Next, call your method as follows:
T_F
= self._myUtility._convertFtToM(T_K)
- Run and test your tool to make sure it works.
Click here for Answer to Exercise Utility-1.