Please enable JavaScript to view this site.

Knowledge Bridge Documentation

Help version: 3.3.8

 

Below is an example of a Method defined on a Design in kBridge.

 

MethodSyntax1

 

It is created just like creating any other Rule, using the Add button.  The data type (1) is the data type to be returned from the method. A Method must have the Method flag set (2) and no others.

 

Methods are defined using the anonymous function syntax from JavaScript with "return " in front of it—"anonymous" because the function has no name.

 

The example above is a Method that takes two vectors as arguments and returns true if they are parallel within a tolerance.

 

The first "return" in the formula tells JavaScript to return the function object. kBridge then stores that function definition as the value of the Method Rule so kBridge can run it later when demanded. The second "return" is actually inside the function definition and tells the method what value to return when it is evaluated.

 

JavaScript functions allow for optional arguments and "rest" arguments. The syntax of those things is left for search.

 

Calling a Method

Calling a method is just like referencing any other rule in kBridge, except there are arguments:

 

this.parallel(v(1,0,0), v(3,0,0))

 

will return "true".

 

If the return value of a method is another model or object, the refChain can continue:

 

this.method1(…).length

Knowledge Bridge from Engingeering Intent is a full-featured engineering and sales automation environment