Creating a Reusable Function

You must first create the reusable function. In this tutorial, you are going to create a function that checks if three points are aligned.

Click Play to watch the video:

  1. From the Compass, click the 3D Modeling Apps quadrant, and select Quality Rules Capture.
  2. In the Know-how Libraries section, click Create Know-how Library .
    The Know-how Library dialog box opens.
  3. Enter a name in the Title box and click OK.
  4. In the Know-how Libraries section, click Create Know-how Function .
    The Create Library Function dialog box opens.
  5. Enter the function name and click OK.
    The function appears under the library it is linked to below the Know-how Libraries in the tree.
  6. Double-click the function in the tree.
    The EKL Function Editor appears.
  7. Declare the function arguments.
  8. Enter your script.
    1. Declare the variables.
      let l1,l2(Line)
      let d1,d2(Direction)
      let v1,v2(Vector)
      let scalProd(Real)
      let prdVect(Vector)
    2. Build the lines from these points.
      l1 = line(iPt1,iPt2)
      l2 = line(iPt1,iPt3)
    3. Compute the direction from the lines.
      d1 = direction(l1)
      d2 = direction(l2)
    4. Turn the direction into mathematical vectors.
      v1 = d1->Vector()
      v2 = d2->Vector()
    5. Create a cross product on the vectors.
      prdVect = CrossProduct(v1,v2)
      if prdVect == [ 0, 0, 0 ]
                      ToReturn = TRUE
      else
                      ToReturn = FALSE
      
      Note: if the cross product result is the null vector, the points are aligned. The ToReturn variable is used to store the returned value of the function.