Smart Tools Utilities

Edit Action Windows
Exercise Utility-1 -- Making a Utility to Share Among Smart Tools and Procedures

Utilities

Edit Action Windows

So far, we have modified Smart Tools and Procedures. We will look at Utilities.
  1. From the Localization perspective, choose GFE-->Utilities.
You will see some utilities listed including the SmartScript library which you can view from the MB3 popup over the window. You can add Python modules here which might contain methods you wish to share among the Smart Tools and Procedures you've created.

Exercise Utility-1 -- Making a Utility to Share Among Smart Tools and Procedures

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.
  1. In Localization perspective under the GFE section, on the Utility folder, select MB3-->New.
  2. Name your Utility and select OK.
  3. 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.
  4. 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)
     
  5. Run and test your tool to make sure it works.
Click here for Answer to Exercise Utility-1.