Defining Functions and Methods      

This scenario is designed to show you how to create a method and a function interactively. This function and this method will be available in all Knowledge browsers. You are going to create a function and a method designed to get the diameter of a hole.
This functionality is designed to help you define new functions or methods without having to go through C++ programming. It can be accessed by clicking the Add Function/Method icon () in the Technological Object toolbar. These functions/methods are:
  • Stored in .CATfct files that may already contain technological types or processes.
  • Displayed in the Tree view under a specific node called Knowledge functions.

For more information, see About Knowledgeware Functions and Methods.

Open an existing .CATfct file.

Define a Method

  1. In the Technological Object toolbar, click the Add Function/Method icon (). The Method or Function Creation window opens.

  2. Enter the Method name, GetDiameter in this scenario, in the Method Type field.

  3. Click Method in the Function/Method Selection frame.

  4. Click the ... button in the Method Type field and select the type, Hole in this scenario, that will be returned in the Choose Type Argument dialog box. Click OK when done.

  5. Click the ... button in the Argument(s) field. The Choose Type Argument dialog box is displayed.

  6. Enter the name of the argument in the Name of Argument field, DiameterType.

  7. In the Type of Argument frame, click Simple type and select String from the list. Click OK when done.

  8. Click the ... button in the Return Type field. The Choose Type Argument dialog box is displayed.

  9. click Simple type and select LENGTH from the list. Click OK when done.

  10. Enter the body in the editor.

    if (DiameterType == "Normal")
                    ReturnParm = This.Diameter
    else
                    ReturnParm = This.DiameterThread

You are done with the definition of the method.

  1. Click OK when done. The method is created and displayed below the Function/Method View node.

    When you define a method on a given type, it is displayed below this type in the Knowledge Expert browser.

Define a Function

  1. In the Technological Object toolbar, click the Add Function/Method icon (). The Method or Function Creation window opens.

  2. Enter the name of the function that you want to create, (myGetDiameter) in the Name of Interactive Function field.

  3. Click the ... button in the Argument(s) field. The Choose Type Argument dialog box is displayed.

  4. Enter the name of the argument in the Name of Argument field, H in this example.

  5. In the Type of Argument frame, select Hole from the list. Click OK when done.

  6. Click the ... button in the Return Type field. The Choose Type Argument dialog box is displayed.

  7. click Simple type and select LENGTH from the list. Click OK when done.

  8. Enter the body in the editor. Note that Diameter is one of the attributes of the hole type, which enables you to retrieve it.

    ReturnParm = H.Diameter

You are done with the definition of the method.

  1. Click OK when done. The method is created and is displayed below the Function/Method View node