GRIP Introduction | Declarations and Functions List


Declarations and Functions

This topic covers the declarations and functions in GRIP that are used to define and manipulate user-defined variables. The GRIP functions also deal with extracting and/or performing mathematical operations on the characteristics of objects and characters.

These declarations and functions have been defined in this section:

The declarations in GRIP are used to define and initialize user defined variables. Variables are one of three data types: ENTITY, NUMBER, or STRING. The DATA declaration is used to initialize, or preset values for the variables before the rest of the program executes. Declarations must precede any other lines of code in a GRIP program.

The GRIP functions perform operations which are not normally found in interactive NX. Functions do not, by themselves, create any objects; however, they can be invaluable in performing mathematical calculations needed to model geometry. Most GRIP functions follow the following format:

Major word(variable(s))

Some functions use scalars. Scalars are numerical values used to position the application of a function on a curve or a surface. For example, the CPOSF function returns the coordinates of a point at a distance along a curve. The distance is defined as a scalar value of the total length of the curve. To place the coordinate calculation on the curve, the scalar value must be between 0 and 1. Any value beyond the range of 0 to 1 places the calculation on the extensions of the curve. The format of a function using scalars is generally as follows:

Major word(object,scalar(s))

When data is returned from a function, like the CPOSF function above, it should be assigned to a variable. That variable must have the proper data type and contain enough positions or dimensions to handle the information. For example, the variable which is assigned the coordinates calculated by the CPOSF function must be declared as a three position numerical array. The format of this assignment is generally as follows:

NUMBER/variable(3)
Variable=major word(object,scalar(s))

The CPOSF function would calculate the coordinates of a point along a line and assign them to an array as follows:

ENTITY/LN1,PT1
NUMBER/NUM(3)
LN1=LINE/0,0,4,3
NUM=CPOSF(LN1,.5)
PT1=POINT/NUM
PRINT/NUM
HALT

The above program displays the following output to the listing device:

2.0000,1.5000,.0000

and draws the following line and point.

Line and Mid Point Using CPOSF