0% found this document useful (0 votes)
199 views94 pages

27 - Using Expressions and Variables

This document provides an overview of using expressions and variables in PC-DMIS. It discusses using expressions in measurement routines, creating expressions with the expression builder, understanding expression components, and accessing object properties and scan minimum circle information from expressions. The expression builder allows users to visually construct expressions using available operands, operators, and functions without typing them out directly. Understanding expression precedence and component types is important for ensuring expressions are evaluated correctly.

Uploaded by

sokaiya raman
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
199 views94 pages

27 - Using Expressions and Variables

This document provides an overview of using expressions and variables in PC-DMIS. It discusses using expressions in measurement routines, creating expressions with the expression builder, understanding expression components, and accessing object properties and scan minimum circle information from expressions. The expression builder allows users to visually construct expressions using available operands, operators, and functions without typing them out directly. Understanding expression precedence and component types is important for ensuring expressions are evaluated correctly.

Uploaded by

sokaiya raman
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 94

Table of Contents

Using Expressions and Variables.................................................................................... 1

Using Expressions and Variables: Introduction ........................................................... 1

Using Expressions in a Measurement Routine ............................................................ 2

Viewing Expression Values ...................................................................................... 2

Keeping Expression Values Only ............................................................................. 2

Using Expressions with Branching ........................................................................... 3

Using Expressions with File Input / Output............................................................... 3

Creating Expressions with the Expression Builder....................................................... 3

Creating an Expression by Typing ........................................................................... 4

Creating an Expression with the Expression Builder ................................................ 4

Checking the Expression for Correctness ................................................................ 5

Expression Element Type ........................................................................................ 6

ID ............................................................................................................................. 6

Extension ................................................................................................................. 6

Second Extension .................................................................................................... 8

Add Button ............................................................................................................... 8

Edit Box .................................................................................................................... 9

Description Area....................................................................................................... 9

Using Variables with Expressions ................................................................................ 9

Assigning Values to Variables by Using the Assignment Dialog Box ..................... 10

Understanding Expression Components ................................................................... 10

Operand Types ...................................................................................................... 11

i
Table of Contents

Literals ................................................................................................................... 11

References............................................................................................................. 12

Variables ................................................................................................................ 19

Structures............................................................................................................... 23

Pointers .................................................................................................................. 25

Arrays..................................................................................................................... 27

Operators for Expressions ..................................................................................... 36

Precedence ............................................................................................................ 38

Functions ............................................................................................................... 38

Operand Coercion .................................................................................................. 81

ID Expressions ....................................................................................................... 84

Accessing a Report's Object Properties..................................................................... 87

Accessing Information from a Constructed Scan Minimum Circle ............................. 90

ii
Using Expressions and
Variables
Using Expressions and Variables:
Introduction
An expression is a user-defined condition used with PC-DMIS's flow control commands.
Using flow control statements, you can test these conditions in your measurement
routine. If the condition is met or not, you can determine what action PC-DMIS takes.

Expressions are important to making PC-DMIS accomplish your specific tasks. When
you use expressions in conjunction with flow control commands, you can unleash even
more of PC-DMIS's powerful functionality.

This chapter explains how to create and use expressions inside the PC-DMIS Edit
window. When you work with expressions, you should place the Edit window into
Command mode. This allows you to view the Edit window code directly.

The following major topics are covered in this chapter:

• Using Expressions in a Measurement Routine


• Creating Expressions with the Expression Builder
• Using Variables with Expressions
• Understanding Expression Components
• Accessing a Report's Object Properties
• Accessing Information from a Constructed Scan Minimum Circle

1
Using Expressions and Variables

If you're looking for information on Reporting Expressions, see the "About


Report Expressions" in the "Reporting Measurement Results" chapter.

Using Expressions in a Measurement


Routine
The PC-DMIS Edit window allows expressions in most of its editable fields. Editable
fields are usually those fields that highlight in yellow when you press TAB inside the Edit
window while in Command mode. Fields that change the type of the feature do not allow
expressions.

The box of an auto feature that specifies the type of the auto feature, such as
a Surface point, Auto Circle, Auto Round Slot, and so on, does not allow expressions.

The subtopics under this topic offer a complete reference to available expressions.

Viewing Expression Values


To see the value of an expression, position the mouse cursor over the expression and
leave it in position for at least one second. The expression is evaluated and a small
yellow pop-up window that displays the expression and its current value appears just
below the mouse cursor.

Keeping Expression Values Only


To immediately solve an expression in the Edit window and keep only the value:

1. Select the expression text in the Edit window.


2. Precede the expression text with a ` (accent grave) character.

2
Creating Expressions with the Expression Builder

Suppose you type the expression " `1/7 " in a numeric field. The expression is
immediately solved and only the value (0.143) is placed in the field.

Using Expressions with Branching


The flow control commands use expressions to determine flow of routine execution.
Refer to the "Branching by Using Flow Control" chapter for information on when
branching may or may not occur.

Using Expressions with File Input / Output


Writing data to an external data file or reading data from an external data file often uses
variables and other expressions to effectively manage and store or display that data.
Refer to the "Using File Input / Output" chapter for more information.

Creating Expressions with the


Expression Builder

Expression Builder dialog box

PC-DMIS allows you to create and add expressions into the Edit window by typing them
or using the interface of the Expression Builder dialog box. The Edit | Expression
menu option displays the Expression Builder dialog box.

3
Using Expressions and Variables

This dialog box allows you to create an expression and insert it into an editable field.
Pressing the F2 key while the cursor is on a field that allows expressions also displays
the Expression Builder dialog box.

The Expressions Builder dialog lists all of the types of operators and functions that are
available for expressions.

Creating an Expression by Typing


To create an expression by typing it directly into the Edit window:

1. Open the Edit window (View | Edit Window).


2. Place the Edit window into Command mode.
3. Press TAB to move your cursor to an editable field where you want to insert the
expression. Fields with a yellow highlight are considered "editable".
4. Type the expression.

Creating an Expression with the Expression Builder

You must be in Command mode for the Expression option to be enabled.

To enter an expression by using the Expression Builder dialog box (Edit | Expression):

1. Open the Edit window (View | Edit Window).


2. Place the Edit window into Command mode (View | Command Mode).
3. Move the cursor to an editable field where you want to insert the expression.
4. Press the F2 key while the cursor is on a field that allows expressions. The
Expression Builder dialog box appears. The Expression Builder dialog box
lists all of the operators, operands, and functions. The following can be
referenced through this dialog box:

• Available expression types


• Variables
• Features
• Dimensions
• Alignments
• Comments

4
Creating Expressions with the Expression Builder

5. Select the expression element type from the first drop-down list. Depending on
your selection, other combination boxes appear.
6. Select the desired ID from the ID drop-down list.
7. Select an extension from the Extension drop-down list.
8. Select another extension from the Second Extension drop-down list. If the
expression is usable, the Add button becomes available.
9. Click the Add button. The expression appears in an edit box.
10. Click the OK button. The expression now appears where your cursor is in the
Edit window.

You can also open the Expression Builder dialog box from these other dialog
boxes:

• The If Expression dialog box - Select Insert | Flow Control Command | If


Goto. Click on the Expression button.
• The Assignment dialog box - Select Insert | Assignment. Click the Assign To
or Assign From button.

Once the expression is created, PC-DMIS automatically inserts the expression at the
next legal position in the Edit window.

Checking the Expression for Correctness


When your cursor leaves the field where you added the expression, PC-DMIS attempts
to check the expression for correctness. If there is a problem with the expression, an
error message that indicates an invalid number may appear, or the expression text may
turn red. Also, expressions that refer to non-existent objects appear in red text.

Since the test of expression correctness occurs at the time you leave a field, a field that
turned red due to a reference of a nonexistent object, (ex. CIRCLE1.X) will remain red
even if the new object (for example, CIRCLE1) is added. The field remains red until the
expression is retested for correctness.

To retest the expression for correctness:

1. Move your cursor to the field of the expression.


2. Press the F2 key. The Expression Builder dialog box opens again. Any
changes to your expression appear in the edit box.
3. Press the ENTER key to close the dialog box.

5
Using Expressions and Variables

Expression Element Type


The Expression Element Type drop-down list in the Expression Builder dialog
box (Edit | Expression) lists the various expression element types available to be
placed into expressions. These include:

• Functions
• Operators
• Alignments
• Comments
• Dimensions
• Features
• Variables

ID
The ID drop-down list in the Expression Builder dialog box (Edit | Expression) lists
the set of items available based on the expression element type selected in the
Expression Element Type drop-down list.

• When Functions & Operators is chosen from the Expression


Element Type drop-down list, the ID drop-down list contains a list of the
available functions and operators.
• When Features is chosen in the Expression Element Type drop-down list, the
ID drop-down list displays the IDs of the features in the measurement routine.

Extension
The Extension drop-down list in the Expression Builder dialog box (Edit |
Expression) becomes available when the item chosen in the ID drop-down list requires
the addition of an extension in order to form a usable expression element. The
Extension drop-down list displays available extensions based on the item selected in
the ID drop-down list.

6
Creating Expressions with the Expression Builder

Suppose you select a feature from the ID drop-down list. The list of possible
extensions that can be used to reference data of that feature (such as "X", "Y", "Z",
"Diam", "Length", etc.) are then listed in the Extension drop-down list.

Possible extensions include these measured or theoretical data types:

Measured

• All – All the values of the feature are assigned to the variable. See the example
below.
• X – Measured X values of the hits
• Y – Measured Y values of the hits
• Z – Measured Z values of the hits
• XYZ – Measured XYZ values of the hits
• I – Measured I values of the hits
• J – Measured J values of the hits
• K – Measured K values of the hits
• IJK – Measured IJK values of the hits

Theoretical

• TX – Theoretical X values of the hits


• TY – Theoretical Y values of the hits
• TZ – Theoretical Z values of the hits
• TXYZ – Theoretical XYZ values of the hits
• TI – Theoretical I values of the hits
• TJ – Theoretical J values of the hits
• TK – Theoretical K values of the hits
• TIJK – Theoretical IJK values of the hits

F1=GENERIC/POINT,DEPENDENT,CARTESIAN,$
NOM/XYZ,<8,9,10>,$
MEAS/XYZ,<7.98,8.98,9.98>,$
NOM/IJK,<1,0,0>,$
MEAS/IJK,<1,0,0>

7
Using Expressions and Variables

ASSIGN/MYFEATURE=F1.ALL
ASSIGN/V1=MYFEATURE.X
ASSIGN/V2=MYFEATURE.TX

V1 contains the value of 7.98

V2 contains the value of 8

Second Extension
The Second Extension drop-down list becomes available only if the item chosen in the
Extension drop-down list requires the addition of a second extension in order to form a
usable expression element.

Suppose you are referencing the nominal value of the X location axis of a
dimension named "D1". You would:

1. Choose D1 from the ID drop-down list.


2. Select X from the Extension drop-down list.
3. Select Nom from the Second Extension drop-down list.

Add Button
Whenever you select a usable or complete expression element using the drop-down
lists, the Add button becomes available. This button displays the text to be added to the
expression.

For example, if the following were chosen:

• Dimensions from the Expression Element Type list


• D1 from the ID list
• X from the Extension list
• Nom from the Second Extension list

Then the Add button becomes enabled and would have the following text: Add
D1.X.NOM.

8
Using Variables with Expressions

Upon clicking the Add button, the text then appears in the edit box at the bottom of the
dialog box.

When you click the OK button, the text from the edit box is added to the Edit
window, to the expression field where your cursor is. If you select an item from the Edit
window's expression field, and the text to be added contains parenthesis, then the
selected item would be placed inside of the parenthesis of the added text.

Edit Box
At the bottom of the Expression Builder dialog box (Edit | Expression) is an edit box
that shows the current expression. You can type the expression directly into this box, or
you can use the Add button.

Description Area
The Expression Builder dialog box (Edit | Expression) also contains a Description
area that gives information about items selected from the drop-down lists. A field next to
the Add button also shows the current value of the expression.

Invalid expressions have a value of 0.

Using Variables with Expressions


Variables are objects that hold values. Variables refer to integer, real, string, or point
operands. Variables are essential to using expressions. A variable has a name and a
value. The name is used to access the value of the variable. The name is constant; the
value can be changed. You can use the ASSIGN/ command to assign a value to a
variable.

For example, the statement ASSIGN/V1=2 creates a variable with a name of V1 and a
value of 2. ASSIGN/V2=V1+2 accesses the value of V1. If V1 still had a value of 2
when this assign statement was executed, V2 would then have a value of 4.

9
Using Expressions and Variables

For more information on variables, see "Variables".

Assigning Values to Variables by Using the


Assignment Dialog Box

Assignment dialog box

The Insert | Assignment menu option displays the Assignment dialog box. Use this
dialog box to assign a value to a variable or data element of a measurement routine
feature, dimension, or alignment. Use of the assignment command requires a basic
understanding of PC-DMIS expressions.

Assign To button - This button designates the variable that is receiving the value
calculated in the Assign From box. Information chosen using the Assign To
button is placed in the Assign To box. This value can be the name of a variable or
a reference to a data element of a feature, dimension, or alignment.

The result of solving the mathematical expression for a value is what is meant by the term
"evaluated".

Assign From button - This button places the value being assigned into the
Assign From box. If this box contains an expression, the expression is evaluated
at execution time and the result or value of the calculation is assigned to the
object specified in the Assign To box.

Insert button - This button inserts an assignment command into the measurement
routine while keeping the Assignment dialog box open. A series of assignment
commands can be inserted without closing the dialog box.

Understanding Expression Components


Expressions have these types of operands:

• Integers
• Real Numbers
• Strings

10
Understanding Expression Components

• Points
• Feature Pointers
• Arrays
• Functions

These are discussed in detail below.

Operand Types
The operands may exist in the form of:

• Literals
• References
• Variables
• Structures
• Pointers
• Arrays

Literals
*Integers: 1, -6, 209

Reals: 1, -6, 2.4, -0.1, 345.6789

Strings: "Hello World", "47", "CIRCLE 1"

Points: A literal representation is not available for points. However, points can be made
from other literals using the MPOINT function: For example,
MPOINT(0,0,1), MPOINT(2.2,3.1,4.0).

Pointer: The name of a feature enclosed in French brackets: {CIR1},{LIN2},{F3}

Arrays: A literal representation is not available for arrays. However, arrays can be
created from other literals using the ARRAY function: For example, ARRAY(3,5,6),
ARRAY("Hello",2.3,9). These functions create 3 element arrays with the integer
elements 3, 5, and 6 in the first example and the string element "Hello", double element
2.3, and integer element 9 in the second example.

Functions: A literal representation is not available for functions. Functions are defined
using the FUNCTION keyword and accessed via variable ids. For example,

11
Using Expressions and Variables

ASSIGN/Add2=FUNCTION((X),X+2) defines a function that takes one argument and


adds 2 to it. The variable Add2 is assigned the function. The function can be called
using the variable Add2 as follows. ASSIGN/Result=Add2(5). Result is assigned the
value 7.

Numeric Literals are interpreted as real numbers unless the operator or


function implies the use of integers. For example, the expression 10 / 8 evaluates to
1.25 instead of 1. Note also that discrete division is also possible via the operand
coercion operators. The expression INT(10) / INT(8) does evaluate to 1.

References
References refer to data members of other objects in a measurement routine.
References use the ID of an object in the measurement routine followed by a dot and an
extension that refers to the data member of the object.

If CIRCLE1 were the name of a measured circle in the measurement routine,


CIRCLE1.X would refer to the measured value of the X component of CIRCLE1. All
references are evaluated in part coordinates relative to the current alignment.

References of Type Double


The following reference expressions are available:

Valid Extensions for Feature References of Type Double by Example

Format: <Feature Id>.<Extension> -> CIRCLE1.X

CIRCLE1.X Measured X Value of CIRCLE1


CIRCLE1.Y Measured Y Value of CIRCLE1
CIRCLE1.Z Measured Z Value of CIRCLE1

CIRCLE1.TX Theoretical (Nominal) X Value of CIRCLE1


CIRCLE1.TY Theoretical (Nominal) Y Value of CIRCLE1
CIRCLE1.TZ Theoretical (Nominal) Z Value of CIRCLE1

12
Understanding Expression Components

LINE1.SX Measured X Value of the Startpoint of LINE1


LINE1.SY
LINE1.SZ

LINE1.TSX Theoretical X Value of the Startpoint of LINE1


LINE1.TSY
LINE1.TSZ

LINE1.EX Measured X Value of the Endpoint of LINE1


LINE1.EY
LINE1.EZ

LINE1.TEX Theoretical X Value of the Endpoint of LINE1


LINE1.TEY
LINE1.TEZ

POINT.I Measured I Component of Vector for POINT


POINT.J
POINT.K

POINT.TI Theoretical I Component of Vector for POINT


POINT.TJ
POINT.TK

FEAT1.TYP The type of the feature (i.e. circle, slot, cone). This can be used to change
the type of a generic feature (ASSIGN/Gen1.TYP=Feat1.TYP).

FEAT1.ALL Refers to all elements of the feature. This is valuable for copying
information to a generic feature. (ASSIGN/Gen1.ALL=Feat1.ALL)

Surface Vector

EDGE.SURFI

EDGE.SURFJ

EDGE.SURFK

EDGE.TSURFI

EDGE.TSURFJ

EDGE.TSURFK

13
Using Expressions and Variables

Angle Vector

CIR.ANGI

CIR.ANGJ

CIR.ANGK

CIR.TANGI

CIR.TANGJ

CIR.TANGK

Radius

CIRCLE1.R

CIRCLE1.TR

CIRCLE1.RAD

CIRCLE1.TRAD

CIRCLE1.RADIUS

CIRCLE1.PR – Polar Radius

CIRCLE1.TPR – Theoretical Polar Radius

CIRCLE1.TRADIUS (Only the First Characters are significant)

Diameter

CIRCLE1.D

CIRCLE1.TD

CIRCLE1.DIAM

CIRCLE1.TDIAM

CIRCLE1.DIAMETER

CIRCLE1.TDIAMETER (Only the first characters are significant)

14
Understanding Expression Components

Angle

CONE.A

CONE.TA

CONE.ANG

CONE.TANG

CONE.ANGLE

CONE.TANGLE

CONE.PA – Polar Angle

CONE.TPA – Theoretical Polar Angle (Only the first characters are significant)

Length

LINE.L

LINE.TL

LINE.LEN

LINE.TLEN

LINE.LENGTH

LINE.TLENGTH (Only the first characters are significant)

Height

CYLINDER.PH – Polar Height

CYLINDER.TPH – Theoretical Polar Height

Radius, Angle, Height

POINT.RAH – Point with Measured Radius, Angle, and Height

POINT.TRAH – Point with Theoretical Radius, Angle, and Height

15
Using Expressions and Variables

Area

BLOB1.AREA - Returns the measured Area value for a Blob feature.

BLOB1.TAREA - Returns the Theoretical Area value for a Blob feature.

For example, ASSIGN/V1=BLOB1.AREA returns the measured area value of the


BLOB1 feature and assigns it to the V1 variable.

Currently, only the Blob feature works with these area extensions. For information on
the Blob feature, see the "Vision Blob" topic in the "PC-DMIS Vision" documentation.

Valid Extensions for Dimension Reference of Type Double by Example

Format: <Dimension ID>.<AXIS>.<Dimension Element> -> DIM1.X.NOM

DIM1.X.NOM The Nominal Value for X Axis Location of DIM1

DIM1.X.MEAS The Measured Value for the X Axis Location of DIM1

DIM1.X.MAX The Max Deviation for X Axis Location of DIM1

DIM1.X.MIN The Min Deviation for X Axis Location of DIM1

DIM1.X.PTOL The Plus Tolerance Value for the X Axis Location of DIM1

DIM1.X.MTOL The Minus Tolerance Value for the X Axis Location of DIM1

DIM1.X.DEV The Deviation on the X Axis Location of DIM1

DIM1.X.OUTTOL The Out of Tolerance value on the X Axis Location of DIM1

DIM1.Y.NOM The Nominal Value for the Y Axis Location of DIM1

DIM1.Z.DEV The Deviation on the Z Axis Location of DIM1

DIM3.PA.MEAS The Measured Value for the Polar Angle Location of DIM3

DIM4.M.PTOL The Plus Tolerance Value for the M Axis of DIM4

The Plus Tolerance Value for the M Axis of DIM4 (See *Note
DIM4.PTOL
under "Valid Axes " below).

DIM5.BTOL The Bonus Tolerance Value where DIM5 is a Position.

16
Understanding Expression Components

Valid Axes:

X, Y, Z, D, R, A, T, V, L, PR, PA, M, PD, RS, RT, S, H, DD, DF, TP

* Dimensions that have only one axis by definition (such as roundness,


concentricity, and so on) can omit the axis qualifier. If the axis qualifier is used, note that
all of these types of dimensions (that have only one axis) use the M Axis qualifier with
the exception of 2D and 3D angle dimensions, which use the A Axis qualifier.

Valid Extensions for Alignment References of Type Double by Example:

Format: <Alignment ID>.<Alignment Axis or Origin>.<Alignment Axis or Origin


Component> -> A1.ORIGIN.X

A1.ORIGIN.X X Component of alignment A1's measured origin

A2.ORIGIN.Y Y Component of alignment A2's measured origin

A1.ORIGIN.Z Z Component of alignment A1's measured origin

A1.XAXIS.I I Component of alignment A1's measured X axis

A1.YAXIS.J J Component of alignment A1's measured Y axis

A1.ZAXIS.K K Component of alignment A1's measured Z axis

X Component of alignment A1's origin based on theoretical (C is


A1.CORIGIN.X
for CAD) data

J Component of alignment A1's X axis based on theoretical (C is


A1.CXAXIS.J
for CAD) data

References of Type Point


The following reference expressions are available:

Valid Extensions for Feature References of Type Point by Example

Format: <Feature ID>.<Extension> -> CIRCLE1.XYZ

17
Using Expressions and Variables

CIRCLE1.XYZ Measured centroid of CIRCLE1

CIRCLE1.TXYZ Theoretical centroid of CIRCLE1

LINE1.SXYZ Measured start point of LINE1

LINE1.TSXYZ Theoretical start point of LINE1

LINE1.EXYZ Measured end point of LINE1

LINE1.TEXYZ Theoretical end point of LINE1

CIRCLE1.IJK Measured Vector of CIRCLE1

CIRCLE1.TIJK Theoretical Vector of CIRCLE1

EDGE.SURFIJK Measured Surface Vector of EDGE

EDGE.TSURFIJK Theoretical Surface Vector of EDGE

AUTOCIR1.ANGIJK Measured Angle Vector of AUTOCIR1

AUTOCIR1.TANGIJK Theoretical Angle Vector of AUTOCIR1

Valid Extensions for Alignment Reference of Type Point by Example

Format: <Alignment ID>.<Alignment Axis or Origin> -> A1.XAXIS

A1.ORIGIN Measured origin of alignment A1

A1.XAXIS Measured X axis of alignment A1

A1.YAXIS Measured Y axis of alignment A1

A1.ZAXIS Measured Z axis of alignment A1

A1.CORIGIN Theoretical origin of alignment A1

A1.CXAXIS Theoretical X axis of alignment A1

18
Understanding Expression Components

A1.CYAXIS Theoretical Y axis of alignment A1

A1.CZAXIS Theoretical Z axis of alignment A1

References of Type String


References to comments are the only object types that are of type string. Only INPUT
comments or YES/NO comments can be referred to via references. These comment
types have an ID that you can use to identify the comment.

Format: <Comment ID>.INPUT -> C1.INPUT

C1.INPUT - The input value (from the operator) for comment C1

YES/NO comment types set the input to the appropriate yes or no string based on the
current language of PC-DMIS. In the English version of PC-DMIS, if the operator
presses the yes button, the string is set to "YES". If the operator presses the no button,
the string is set to "NO". When comparing strings to test for "YES" or "NO", the
comparison is case sensitive. Thus, comparing against "yes" or "no" always fails even if
the YES/NO comment input is set to "YES" or "NO".

Variables
Variables can be of any of the seven operand types: integer, real, string, point, feature
pointer, array, and function. Variables come into existence and receive their value and
type via the ASSIGN statement. The variable ID can be any alphanumeric string that
does not begin with a numeric character. Underscores can also be used in the variable
id provided that the underscore is not the first character.

Variable values are saved between execution runs. This means if routine execution
stops and re-starts, the values the variables have when execution stops will be the
same values when execution starts again.

19
Using Expressions and Variables

If the Edit window is active, PC-DMIS indicates the current value of the
variable whenever the cursor is placed in the field. During execution, variable values
change based on execution flow. Position the mouse pointer over the desired variable
to find out its current value.

ASSIGN/V1=2.2+2
Variable V1 is a real number with the value of 4.2

ASSIGN/VAR1=CIRCLE1.X
Variable VAR1 is a real number with a value equal to the measured value of
CIRCLE1.X at the time of assignment.

ASSIGN/MYVAR=LINE1.XYZ
Variable MYVAR is a point with the same value of the measured centroid of LINE1
at the time of assignment.

ASSIGN/SVAR="Hello World"
Variable SVAR is a string with the value "Hello World"

In these examples, variables are being assigned values. Once a variable has been
assigned a value, you can use the variable as an operand in any expression field.

Here, V1 is used in a numeric field. It is used as the prehit value of the prehit
command:

ASSIGN/V1=1/3PREHIT/V1

Since expressions can be used in most editable fields, the following


expression is also legal and has the same effect: PREHIT / 1/3.

The components of variables of type point can be referred to individually using the dot
extension notation used for references.

ASSIGN/V1=MPOINT(3,4,5)
V1 is of type point with value of 3, 4, 5

ASSIGN/XVAR=V1.X
XVAR is of type double with the value of 3

20
Understanding Expression Components

ASSIGN/YVAR=V1.Y
YVAR is of type double with the value of 4

ASSIGN/IVAR=V1.I
IVAR is of type double with the value of 3

ASSIGN/REDUNVAR=V1.XYZ
REDUNVAR is of type point with the value of 3, 4, 5

The following extensions are equivalent to each other. Both are provided to clarify the
meaning of an expression in a measurement routine.

Given that V1 is of type point.

V1.X is the same as V1.I


V1.Y is the same as V1.J
V1.Z is the same as V1.K

V1.XYZ is the same as V1.IJK and V1 without any extension.

If a variable of type string has a string value equal to the name of the id of a feature,
dimension, or alignment, the variable can be used as a reference object:

ASSIGN/V1="CIRCLE1"

The following operands are possible and valid provided a feature with the name
CIRCLE1 exists.

V1.X - The measured X value of CIRCLE1


V1.TX - The theoretical X value of CIRCLE1
V1.Diameter - The measured diameter of CIRCLE1
V1.Radius - The measured radius of CIRCLE1

This type of indirection available on string variables is only available to one level of
indirection. The following will not work.

ASSIGN/V1="CIRCLE1"
ASSIGN/V2="V1"

V2.X - This will evaluate to 0 instead of the current measured value of


CIRCLE1.X.

21
Using Expressions and Variables

The reference V2.X will not be flagged as an error with red text even
though an expression above it sets its type to a string. The reason it cannot be
flagged as an error is because the flow of execution of the measurement routine is
not known until execute time.

However, if you use curly brackets the following does work:

ASSIGN/V1={CIRCLE1}
ASSIGN/V2={V1}

V2.X - This will give you the value of CIRCLE1.X.

Consider the following example:

ASSIGN/V1="CIRCLE1"
ASSIGN/V2="V1"
IF/CIRCLE1.X>CIRCLE1.TX,GOTO,L2
L1=LABEL/
ASSIGN/V3=V2.X
GOTO/LABEL,L3
L2=LABEL /
ASSIGN/V2=MPOINT(2,5,7)
GOTO/LABEL,L1
L3=LABEL/

If during routine execution the value of CIRCLE1.X is greater than the value of
CIRCLE1.TX, then the expression V2.X will be valid and will evaluate to 2. Otherwise,
the expression V2.X will evaluate to 0 since the value of V2 at the time of the ASSIGN
for V3 is the string "V1". It is the responsibility of the part programmer to ensure that
expressions will do as expected in these cases.

22
Understanding Expression Components

Almost all of the feature references can be used on the left-hand side of the
ASSIGN statement to put a value into a measured or theoretical data member of a
feature. The only exception is the single I, J, K components of vectors. To assign to
vectors, the complete vector must be assigned at once using an expression that
evaluates to a point. Vector data is normalized as it is input into the feature’s vector data
members.

ASSIGN/CIRCLE1.I=2-illegal
ASSIGN/CIRCLE1.IJK=MPOINT(2,0,0)-legal(vector is normalized to
1,0,0)

For information on using variables within dimensions, see the "Dimensioning Variables"
topic in the "Using Legacy Dimensions" chapter.

Structures
You can use a variable type called structures to place extensions on a variable to
identify a sub-element of that variable. Consider this example:

ASSIGN/V1.HEIGHT=6
ASSIGN/V1.WIDTH=4.3
ASSIGN/V1.MODE="CIRCULAR"
ASSIGN/V1.POINT=MPOINT(100.3,37.5,63.1)

In this example:

• V1 is the structure.
• HEIGHT, WIDTH, MODE, and POINT are sub-elements of the structure.

Rules for Structures


• Like Variables, structures do not need to be declared.
• Sub-elements of a structure can be any of these variable types:

23
Using Expressions and Variables

o Integer
o Double
o Point
o Feature Pointer
o Function
o Array
o Structure

For example, it is possible to have structure elements that are arrays and array
elements that are structures. This makes the following example expressions valid:

ASSIGN/CAR.LEFTSIDE.DOOR[2].QUADRANT[3].JOINT[5].HIT[4]=MP
OINT(558.89,910.12,42.45)
COMMENT/OPER,"Current Z Position:
"+CAR.LEFTSIDE.DOOR[2].QUADRANT[3].JOINT[5].HIT[4].Z
ASSIGN/CURRENTJOINT=LEFTSIDE.DOOR[2].QUADRANT[3].JOINT[5]
COMMENT/OPER,"Next Hit: "+CURRENTJOINT.HIT[4]

Structures with Variables of Type Point


If a variable is of type point, the user can still use the .X, .Y, .Z, .I, .J, and .K extensions
to get at individual items of the point. The user can also use any of the extensions from
this example in their structures without being forced to use them as point elements .

ASSIGN/V1.X="Some string"
ASSIGN/V1.Y=ARRAY(1,3,5,9,7)
ASSIGN/V1.Z=MPOINT(3,5,7)

COMMENT/REPT,V1.X Output is "Some string"

COMMENT/REPT,V1.Y[2] Output is 3, the second element of the array.

24
Understanding Expression Components

COMMENT/REPT,V1.Z.Y Output is 5, the Y value of the MPOINT.

By combining structures with the function capability of the PC-DMIS expression


language, it is possible to have dynamic structure references as shown here:

ASSIGN/DYNAMICSTRUCT=FUNCTION((X,Y),X.Y)
C1=COMMENT/INPUT,Please enter in item
ASSIGN/TESTSTR=C1.INPUT
ASSIGN/FRONT=LEFT(TESTSTR,INDEX(TESTSTR,".")-1)
ASSIGN/BACK=MID(TESTSTR,INDEX(TESTSTR,"."))
ASSIGN/RESULT=DYNAMICSTRUCT(FRONT,BACK)

This portion of the example asks you to input a variable reference, splits the
reference at the first '.', and then assigns RESULT to be equal to that reference by using
the function DYNAMICSTRUCT.

So, if from you had typed V1.Y[4] for the C1.INPUT variable, RESULT would end up
with the value of 9 (the fourth element of the array assigned to V1.Y).

The learn time evaluation of expressions has been enhanced to accurately show all
elements of a structure or an array.

Pointers
Pointers are also known as "Feature Pointers ". See the Glossary term "Feature Pointers" for
more information.

Pointers provide a way to reference a feature via a variable or to pass objects using the
call sub command. Pointers are similar to indirection via string names. However, the
advantage of using pointers is with subroutines. Pointers, unlike strings, when passed in
as arguments of a subroutine, allow for direct modification of the object pointed to by the
subroutine. Pointers are not used in complex expressions. If it is used in a complex
expression, the pointer evaluates to zero.

Consider the following examples.

Pointer Use Example:


• ASSIGN/V1={CIR1}

25
Using Expressions and Variables

V1 is now a pointer that points to CIR1.

• ASSIGN/DIST=DOUBLE(V1.XYZ)

Dist = distance of CIR1 from origin.

You can also put an expression between curly brackets in order to obtain a feature
pointer. Now the following examples are all legal ways to get the pointer to feature
CIR1:

• ASSIGN/FEATCOUNT=1

ASSIGN/V1={"CIR"+FEATCOUNT}

Assigns expression "CIR1" to V1.

• ASSIGN/V2="CIR1"

ASSIGN/V3={V2}

Assigns expression "CIR1" from variable V2 to variable V3.

• C1=COMMENT/INPUT,Please type a feature name.

ASSIGN/V4={C1.INPUT}

This takes the feature name of C1.INPUT and places it into variable, V4.

Subroutine Example:

In the calling routine:

CS1=CALLSUB/SUB.PRG,CHANGEX,{CIR1}

In the subroutine:

GEN1=GENERIC/FEATURE
SUBROUTINE/CHANGEX,ARG1={GEN1}

(When CIR1 is passed in it takes the place of GEN1)

ARG1.X=5

(Sets the measured X value of CIR1 to 5)

26
Understanding Expression Components

END/SUBROUTINE

Complex Expression Example:


ASSIGN/V1={CIR1}+2

{CIR1} evaluates to zero and so entire expression evaluates to 2.

Arrays
Three types of arrays are available: Feature, hit, and variable.

Even though multi-dimensional arrays are displayed as multi-dimensional in the


software, you can really only use them as single dimensional arrays until you precede
the arrays with an ARRAY INDICES command (see the "Array Indices Object:" topic).

Feature Arrays
When a feature is measured more than once during routine execution, a feature array is
automatically created. The number of elements in the feature array is equal to the
number of times the feature has been executed.

If a measured circle object were located in a while loop that executed five
times, then an array of five measured circles would exist. If the id of the measured circle
were "Circle1", then an array expression could be used to access individual instances of
the measured circle object. Square brackets are used to indicate the instance desired.

ASSIGN/V1=Circle1[3].X
V1 is assigned the measured X value of the third instance of Circle1.

27
Using Expressions and Variables

When a feature array exists for a given feature, but array notation is not used
in a reference to that feature, the most recent instance is used. From the above
example, the reference Circle1.X would be the same as Circle1[5].X, since the
fifth instance would be the most recent instance of the object.

Expressions can be used within the square brackets of an array expression.


Circle1[3].X and Circle1[2+1].X would therefore be equivalent. The following
example uses a loop to print out the measured centroid of the five circles from the
examples above.

ASSIGN/V1=1
While/V1<6
Comment/Rept,"Centroid of instance #"+V1+" of
Circle1: "+Circle1[V1].XYZ
ASSIGN/V1=V1+1
End/While

Possible output from the above example:

Centroid of instance #1 of Circle1: 3.4, 2.6, 1.43


Centroid of instance #2 of Circle1: 4.4, 3.6, 2.43
Centroid of instance #3 of Circle1: 5.4, 4.6, 3.43
Centroid of instance #4 of Circle1: 6.4, 5.6, 4.43
Centroid of instance #5 of Circle1: 7.5, 6.6, 5.43

Arrays also exist on dimensions and alignments that have been executed multiple times
in a given execution run. Thus, Dim1[2].Nom and Align1[4].Origin would be
available given that the Dimension "Dim1" has executed at least twice and the
alignment "Align1" has executed at least four times.

If a feature array reference is out of bounds (for example, the user asks for
Circle1[2.5] or > Circle1["Hello, World"]) the upper or lower bound item is
returned. If Circle1 had 3 instances then Circle1[4] and above would return the
value for Circle1[3] and Circle[0] and below would return the value for
Circle1[1]. All expressions between square brackets are coerced to integer, thus 2.5
would become 2 and "Hello World" would become 0.

28
Understanding Expression Components

Array Indices Object


By default, feature arrays are always one-dimensional arrays. If it is more convenient to
treat a feature array as a multi-dimensional array, this can be done by using the array
indices object.

The array indices object allows you to specify upper and lower bounds for multiple array
dimensions.

• By setting the upper and lower bounds of the first dimension a two dimensional
array is created where the first dimension is bound and the second dimension is
unbound.
• By setting the upper and lower bounds of the first two dimensions of an array, a
three dimensional array is created. The last dimension is always unbound.

29
Using Expressions and Variables

Feature F1 is located inside a nested WHILE loop. The inner WHILE loop
executes five times and the outer WHILE loop executes three times. At completion of
execution, F1 has been executed 15 times and so 15 instances of F1 exist.

Consider the following example measurement routine segment:

ARRAY_INDICES/1..5,..
ASSIGN/V1=1
WHILE/V1<=3
ASSIGN/V2=1
WHILE/V2<=5
F1=FEAT/POINT,RECT
THEO/V2,V1,0,0,0,1
ACTL/1,1,0,0,0,1
MEAS/POINT,1
HIT/BASIC,V2,V1,0,0,0,1,1,1,0
ENDMEAS/
ASSIGN/V2=V2+1
COMMENT/REPT,"Location of F1["+V2+","+V1+"] :"+F1[V2,V1].XYZ
END_WHILE/
ASSIGN/V1=V1+1
END_WHILE/

This code segment creates a 3 X 5 grid of 15 measured points.

The array indices command has limited the first dimension of the feature array to be
between 1 and 5 inclusively. Thus on the inspection report, instead of appearing as
F1[1] – F1[15], the objects will appear as F1[1, 1] – F1[5, 3], more consistent with the
layout of the features. Notice that the comment also refers to the feature array using a
two dimensional array syntax.

To insert an array_indices object in a measurement routine:

1. Using the keyboard, type "Array" on an empty line in the Edit window.
2. Press the Tab key on your keyboard.

30
Understanding Expression Components

If the Display Brackets for Feature Arrays check box has been cleared, the
feature will not appear with the bracketed name. See "Display Brackets for Feature
Arrays" in the "Setting Your Preferences" chapter.

Hit Arrays
The hits of a given feature are available as an array and can be accessed via
expressions using array syntax of the form <FeatID>.Hit[<Array
Expression>].<Extension> or the form <FeatID>.RawHit[<Array
Expression>].<Extension>. Hit returns probe compensated data when probe
compensation is on. RawHit always return uncompensated data. Valid extensions are
X, Y, Z, I, J, K, TX, TY, TZ, TI, TJ, TK, XYZ, TXYZ, IJK, and TIJK

Circle1.Hit[1].XYZ
The measured centroid (probe compensated) of hit 1 of "Circle1".

Circle1.Hit[2].IJK
The measured vector of hit 2 of "Circle1"

Hit data is available for all objects that have hits, whether the actual hits are displayed in
the Edit window or not. Thus, hits can be obtained for scans and auto features.

The following topics describe some additional array functions that are useful for finding
the minimum or maximum points in a scan:

Assigning a Range of Hits to an Array

You can also assign a range of hits to an array by using this syntax:

<Feature Id>.<Hittype>[<Startnum>..<Endnum>].<Extension>

where

<Feature Id> is the name of the feature.

<Hittype> can be either the word "HIT" for compensated data or "RAWHIT" for
uncompensated data. If probe compensation if turned off, the returns values are
always uncompensated.

<Startnum> is an expression that identifies the first index value of the range of
hits.

31
Using Expressions and Variables

<Endnum> is an expression that identifies the second index value of the range of
hits.

<Extension> identifies the type of data. Possible extensions include these


measured or theoretical data types:

Measured

• X – Measured X values of the hits


• Y – Measured Y values of the hits
• Z – Measured Z values of the hits
• XYZ – Measured XYZ values of the hits
• I – Measured I values of the hits
• J – Measured J values of the hits
• K – Measured K values of the hits
• IJK – Measured IJK values of the hits

Theoretical

• TX – Theoretical X values of the hits


• TY – Theoretical Y values of the hits
• TZ – Theoretical Z values of the hits
• TXYZ – Theoretical XYZ values of the hits
• TI – Theoretical I values of the hits
• TJ – Theoretical J values of the hits
• TK – Theoretical K values of the hits
• TIJK – Theoretical IJK values of the hits

For example:

ASSIGN/V1=SCAN1.HIT[1..10].X
V1 is assigned to an array of 10 values, which are the measured X values from
the first 10 hits of SCAN1.

ASSIGN/V2=SCAN1.HIT[1..SCAN1.NUMHITS].XYZ
V2 is assigned to an array of points from each of the centroids of the hits in the
scan.

Sorting Arrays

PC-DMIS allows you to sort arrays in either ascending or descending order. The
following two expressions take an array and return a sorted array:

32
Understanding Expression Components

To sort in ascending order use:


SORTUP(<array>)

To sort in descending order use:


SORTDOWN(<array>)

For example:

ASSIGN/V1=ARRAY(5,8,3,9,2,6,1,7)
V1 is assigned the array of "5,8,3,9,2,6,1,7".

ASSIGN/V2=SORTUP(V1)
V2 will hold the array values sorted in ascending order: "1,2,3,5,6,7,8,9".

ASSIGN/V3=SORTDOWN(V1)
V3 will hold the array values sorted in descending order: "9,8,7,6,5,3,2,1".

Returning the Greatest or Least Index Values from an Array

You can input an array into a function and return the index number of the element that
has the greatest or the least value by using these functions:

To return the index value of the element with the greatest value, use:

MAXINDEX(<array>)

To return the index value of the element with the least value, use:

MININDEX(<array>)

For example,

ASSIGN/V1=ARRAY(5,8,3,9,2,6,1,7)
V1 is assigned the array of "5,8,3,9,2,6,1,7".

ASSIGN/V2=MAXINDEX(V1)
V2 will hold the array's index value of 4. The actual value of that array element is
9.

ASSIGN/V3=MININDEX(V1)
V3 will hold the array's index value of 7. The actual value of that array element is
1.

You can then use returned index values to get the actual array element value.

33
Using Expressions and Variables

Returning Sorted Index Values from an Array

You can input an array into a function, sort the array's values in ascending or
descending order, and then return the index values by using these functions:

To return the array's index positions in order of their values sorted from greatest to
least use:
MAXINDICES(<array>)

To return the array's index positions in order of their values sorted from least to
greatest use:
MININDICES(<array>)

For example:

ASSIGN/V1=ARRAY(4,8,2,9,5,7)
V1 is assigned the array of "4,8,2,9,5,7".

ASSIGN/V2=MAXINDICES(V1)
V2 will hold an array with these values: "4,2,6,5,1,3".

ASSIGN/V3=MININDICES(V1)
V3 will hold an array with these values: "3,1,5,6,2,4".

Example of Using Array Functions to Find the Minimum and Maximum


Points in a Scan

The main purpose of the hit array functions discussed above is to give you an easy way
to find the minimum and maximum points in a scan.

To dimension the point from SCAN1 that has the greatest measured X value, you could
use this expression:

ASSIGN/MAXPTINDEX=MAXINDEX(SCAN1.HIT[1..SCAN1.NUMHITS].X)
D1=LOCATION OF FEATURE SCAN1.HIT[MAXPTINDEX]

To find the three highest points in the Z axis of SCAN2, you could use this expression:

ASSIGN/MI=MAXINDICES(SCAN2.HIT[1..SCAN2.NUMHITS].Z)
ASSIGN/THREEPOINTS=ARRAY(SCAN2.HIT[MI[1]].XYZ,SCAN2.HIT[MI[2]].X
YZ,SCAN2.HIT[MI[3]].XYZ)

34
Understanding Expression Components

Variable Arrays
Variable arrays do not need to be declared. Variable arrays come into existence via the
assign statement when the expression on the right hand side of the assign statement
evaluates to an array or when the left hand side of the assign statement refers to an
element in a variable array.

ASSIGN/V1=Array(3,4,5,6,7)
Creates 5 element array and assigns it to V1.

ASSIGN/V2=V1[3]
Assigns V2 the value of the third element in array V1: 5.

ASSIGN/V1[4]=23
Assigns 4th element of array V1 to 23.

Arrays are created and allocated dynamically. Thus an array can be created by using an
array reference on the left hand side of an assign statement.

ASSIGN/V3[5]=8
Dynamically creates array with 5th element set equal to 8.

When referencing an array element that has never received a value, the array
expression will evaluate to 0.

ASSIGN/V3[5]=8

ASSIGN/V4=V3[5]
V4 is set equal to the value 8.

ASSIGN/V5=V3[6]
If the sixth element of V3 has never been set, V5 is set equal to 0.

Like other array types, expressions can be used within the square brackets.

ASSIGN/V3[5]=8

ASSIGN/V4=V3[2+3]
V4 is set equal to the value 8.

Variable arrays can have multiple dimensions.

ASSIGN/V6=Array(Array(4,7,2),Array(9,2,6))
V6 is set to a 2 by 3 dimensional array where V6[1, 1] equals 4, V6[1, 2] equals 7,
V6[1, 3] equals 2, V6[2, 1] equals 9, V6[2,2] equals 2, and V6[2,3] equals 6.

35
Using Expressions and Variables

ASSIGN/V7=V6[2,1]
V7 is set to the value 9.

Variable arrays can have negative indexes:

ASSIGN/V8[-3]=5
The –3rd index of array V8 is set to 5.

Array assignment will overwrite previous values:

ASSIGN/V8="Hello"
The variable V8 is equal to the string "Hello"

ASSIGN/V8[2]=5
V8 is no longer of type string, but of type array, the second element of which has a
value of 5.

ASSIGN/V8=9
V8 is no longer an array, but an integer of value 9.

Arrays can be made up of multiple types:

ASSIGN/V9=Array("Hello",3,2.9,{FEAT1})
Creates array V9 with four elements. The first element is a string, the second
element is an integer, the third element is a real number, and the fourth element is
a pointer to FEAT1.

Arrays can be increased in size to include more elements:

ASSIGN/V10=ARRAY(3,1,5)

ASSIGN/V10[LEN(V1)+1]=7
The first statement creates an initial array V10 with three elements (3,1, and 5).
The second statement then grows the array in V10 by one element and gives the
final element a value of 7.

Operators for Expressions


The following basic operators are available inside PC-DMIS:

+ Addition: <Expression> + <Expression>


Adds the two expressions together. In the case of strings, strings are concatenated.

36
Understanding Expression Components

- Subtraction: <Expression> - <Expression>


Subtracts the second expression from the first expression.

* Multiplication: <Expression> * <Expression>


Multiplies the two expressions.

/ Division: <Expression> / <Expression>


Divides first expression by the second expression.

^ Exponentiation: <Expression> ^ <Expression>


Raises the first expression to the power of the second expression.

% Modulo: <Expression> % <Expression>


Returns the remainder of one expression divided by the other.

- Additive Inverse -<Expression>


Returns the additive inverse of the expression.

! Logical Not: !<Expression>


Returns the logical not of the expression.

== Equal To: <Expression> == <Expression>


Evaluates to 1 if expressions are equal. Otherwise, it evaluates to 0. ( Two equal signs
are used to distinguish from the assignment operator = in the assignment statement).

<> Not Equal To: <Expression> <> <Expression>


Evaluates to 1 if expression are not equal. Otherwise, it evaluates to 0.

> Greater Than: <Expression> > <Expression>


Evaluates to 1 if first expression is greater than second expression. Otherwise, it
evaluates to 0.

>= Greater Than or Equal To: <Expression> >= <Expression>


Evaluates to 1 if the first expression is greater than or equal to the second expression.
Otherwise, it evaluates to 0.

< Less Than: <Expression> < <Expression>


Evaluates to 1 if first expression is less than the second expression. Otherwise, it
evaluates to 0.

<= Less Than or Equal To: <Expression> <= <Expression>


Evaluates to 1 if the first expression is less than or equal to the second expression.
Otherwise, it evaluates to 0.

37
Using Expressions and Variables

AND Logical And: <Expression> AND <Expression>


Evaluates to 1 if both expressions does not evaluate to 0. Otherwise, it evaluates to 0.

OR Logical Or: <Expression> OR <Expression> Evaluates to 1 if either expressions


does not evaluate to 0. Otherwise, it evaluates to 0.

() Parenthesis: ( <Expression> )
Gives evaluation to precedence to expression inside of parenthesis.

Precedence
Expressions are evaluated with the precedence shown below (listed from highest
precedence to lowest precedence).

Highest Precedence

• Operands
• (unary minus), !, (), functions (such as ABS, COS, STR, LEN, CROSS, and so
on.)
• ^
• *, /, %
• +, -
• ==, <>, <, <=, >, >=
• AND
• OR

Lowest Precedence

Functions
Functions are PC-DMIS specific expressions or user-defined expressions that usually
take parameters and then return results. The parameters are substituted into the
expression before the expression is evaluated.

Functions List
The following alphabetical list contains all the functions available to PC-DMIS's
expression language.

• ABS (mathematical)
38
Understanding Expression Components

• ACOS (mathematical)
• ANGLEBETWEEN (point)
• ARCSEGMENTENDINDEX (miscellaneous)
• ARCSEGMENTSTARTINDEX (miscellaneous)
• ARRAY (array)
• ASIN (mathematical)
• ATAN (mathematical)
• CHR (string)
• COS (mathematical)
• CROSS (point)
• DEG2RAD (mathematical)
• DELTA (point)
• DIST2D (pointer)
• DIST3D (pointer)
• DOT (point)
• ELEMENT (string)
• EOF (miscellaneous)
• EOL (miscellaneous)
• EQUAL (array)
• EQUAL (string)
• EXP (mathematical)
• FORMAT (string)
• FUNCTION (function)
• GETCOMMAND (pointer)
• GETPROGRAMINFO (string)
• GETROTABDATA (miscellaneous)
• GETSETTING (string)
• GETTEXT (string)
• GETTRACEVALUE (string)
• IF (miscellaneous)
• INDEX (string)
• ISIOCHANNELSET (miscellaneous)
• LEFT (string)
• LEN (array)
• LEN (pointer)
• LEN (string)
• LINESEGMENTENDINDEX (miscellaneous)
• LINESEGMENTSTARTINDEX (miscellaneous)
• LN (mathematical)
• LOG (mathematical)

39
Using Expressions and Variables

• LOWERCASE (string)
• MAX (array)
• MID (string)
• MIN (array)
• MPOINT (point)
• ORD (string)
• PCDMISAPPLICATIONPATH (string)
• PCDMISUSERHIDDENDATAPATH (string)
• PCDMISUSERVISIBLEDATAPATH (string)
• PCDMISSYSTEMHIDDENDATAPATH (string)
• PCDMISSYSTEMVISIBLEDATAPATH (string)
• PCDMISSYSTEMREPORTINGPATH (string)
• PROBEDATA (miscellaneous)
• QUALTOOLDATA (miscellaneous)
• RAD2DEG (mathematical)
• RIGHT (string)
• ROUND (mathematical)
• SETROTABDATA (miscellaneous)
• SIN (mathematical)
• SQRT (mathematical)
• SYSTEMDATE (string)
• SYSTEMTIME (string)
• SYSTIME (string)
• TAN (mathematical)
• TUTORELEMENT (miscellaneous)
• UNIT (point)
• UPPERCASE (string)

String Functions
The following functions are used with text strings.

CHR

Character Conversion: CHR(<Integer>)

This function returns a string, which consists of the character corresponding to the
ASCII decimal value.

40
Understanding Expression Components

ELAPSEDEXECUTIONTIME

Formatted Elapsed Execution Time: ELAPSEDEXECUTIONTIME()

This function returns the time that has elapsed since the measurement routine or
mini routine started to execute. The elapsed execution time is the time spent
during the DCC portion of the execution; it does not track time for pauses due to
attention required by the user. (These include things like execution pauses during
comment execution or PC-DMIS messages. Also, errors messages may stop the
execution altogether.) The time is returned in "hh:mm:ss" format.

You can record the elapsed execution time at any point in the measurement
routine or mini routine by assigning the function to a variable, such as:

ASSIGN/V1=ELAPSEDEXECUTIONTIME()

ELEMENT

Delimited substring location: ELEMENT(<Integer>, <String1>, <String2>)

This function returns the nth substring (element) from string2 using string1 as the
delimiting text that divides the elements in string2.

Suppose string2 is "6, 12, 8, 4, 5" and string1 is a comma character ",".
The five elements that can be individually retrieved with the element command are
"6", "12", "8", "4", and "5".

EQUAL

Case-insensitive string comparison: EQUAL(<String1>, <String2>)

This function compares two strings (ignoring the case) to determine if they are
identical. It returns an integer set to 1 if the strings are the same, and 0 if they are
not.

FORMAT

Format: FORMAT(<String>,<Integer,double, or point>)

This function takes two expressions and returns a formatted string similar to using
the sprintf function inside C++.

41
Using Expressions and Variables

• Expression 1 should be a string type that contains one or three format


specifiers. If it is a different type, the expression evaluator attempts to
coerce it to a string. The string should contain one format specifier if
Expression 2 is an integer or double types and three format specifiers (see
paragraphs below) if Expression 2 is a point type.
• Expression 2 is expected to be of type integer, double, or point. If a
different type is used, the value of the expression is 0.

Format Specifier for FORMAT Function:

The format specifier should have the same syntax as a format specifier used in
the sprintf function used in the C++ programming language.

A format specifier consists of optional and required fields and has the following
syntax:

%[flags] [width] [.precision] type

Each field of the format specifier is either a single character or a number that
signifies a particular format option. The simplest format specifier uses only the
percent sign and a type character (for example, %d). If a percent sign is followed
by a character that has no meaning as a format field, the character is copied to
STDOUT. For example, to print a percent-sign character, use %%.

The optional flag, width, and precision fields, which appear before the type
character, control other aspects of the formatting. These are described below:

flags
These optional characters control output justification and the printing of signs,
blanks, decimal points, and octal or hexadecimal prefixes. More than one flag
can appear in a format specifier.

Here are the possible flags:



Meaning: Left align the result within the given field width.
Default: Right align.
+
Meaning: Prefix the output value with a sign (+ or –) if the output value is of
a signed type.
Default: Sign appears only for negative signed values (–).
0
Meaning: If the width is prefixed with 0, zeros are added until the minimum
width is reached. If 0 and – appear, the 0 is ignored. If 0 is specified with an
integer format (i, u, x, X, o, d) the 0 is ignored.
Default: No padding.

42
Understanding Expression Components

blank (' ')


Meaning: Prefix the output value with a blank if the output value is signed
and positive; the blank is ignored if both the blank and + flags appear.
Default: No blank appears.
#
Meaning 1: When used with the o, x, or X type, the # flag prefixes any
nonzero output value with 0, 0x, or 0X, respectively.
Default 1: No prefix appears.

Meaning 2: When used with the e, E, or f type, the # flag forces the output
value to contain a decimal point in all cases.
Default 2: Decimal point appears only if digits follow it.

Meaning 3: When used with the g or G format, the # flag forces the output
value to contain a decimal point in all cases and prevents the truncation of
trailing zeros.

Default 3: Decimal point appears only if digits follow it. Trailing zeros are
truncated. This is ignored when used with d, i, or u.

width
This second optional field, or argument, controls the minimum number of
characters printed. It is a non-negative decimal integer.

• If the number of characters in the output value is less than the


specified width, blanks are added to the left or the right of the
values — depending on whether the – flag (for left alignment) is
specified — until the minimum width is reached.
• If the width is prefixed with 0, zeros are added until the minimum
width is reached (not useful for left-aligned numbers).
• The width specification never causes a value to be truncated. If the
number of characters in the output value is greater than the
specified width, or if the width is not given, all characters of the
value are printed (subject to the precision specification listed
below).

precision
This third optional field, or argument, specifies the number of characters to be
printed, the number of decimal places, or the number of significant digits.
Unlike the width specification, the precision specification can cause either
truncation of the output value or rounding of a floating-point value. It is a non-
negative decimal integer preceded by a period (.).

43
Using Expressions and Variables

type
This required character determines whether the associated argument is an
integer, a double, or a point. The list of available types includes:

d - signed decimal integer


i - signed decimal integer
o - unsigned octal integer
u - unsigned decimal integer
x - unsigned hexadecimal integer, using "abcdef"
X - unsigned hexadecimal integer, using "ABCDEF"
e - double in exponential form [-]d.dddd e [sign]ddd
E - same as e, except uses E to introduce the exponent
f - double with the form [-]dddd.dddd
g - formats to either the e or f format depending on which is more compact
G - same as g, except uses E to introduce the exponent

FORMAT Example

This example shows several statements using the FORMAT function inside a
measurement routine:

V1 becomes type point


representing the offsets of
the current probe. Using
the values from the
ASSIGN/V1=PROBEDATA("OFFSET")
measurement routine used
for this example, V1
becomes: <-1.8898,
1.8898, 5.704>

V3 becomes type string.


The string is formatted
ASSIGN/V3=FORMAT("%.5f,%.5f,%.5f",V1) using the point object of
variable V1. V3 now has: -
1.88976, 1.88976, 5.70403

ASSIGN/V4=1.123456789 V4 becomes type double.

V5 becomes type string


ASSIGN/V5=FORMAT("%.5f
with this value: 1.12346
",V4)+FORMAT("%.6f ",V4)+FORMAT("%.7f
1.123457 1.1234568
",V4)+FORMAT("%.8f",V4)
1.12345679

V6A becomes type string


ASSIGN/V6A="The value of V4 is:
with value of: The value of
"+FORMAT("%.8f",V4)
V4 is: 1.12345679

44
Understanding Expression Components

The expression result


ASSIGN/V6B=FORMAT("The value of V4 is:
remains the same for
%.8f",V4)
same as V6A above.

V7 becomes type double


since all numbers are
ASSIGN/V7=4444
assumed double unless
coerced to an integer.

V8 becomes type string


ASSIGN/V8=FORMAT("%o",INT(V7))
with this value: 10534

V9 becomes type string


ASSIGN/V9=FORMAT("%u",INT(-1)) with this value:
4294967295

V10 becomes type string


ASSIGN/V10=FORMAT("%x",INT(2143))
with this value: 85f

V11 becomes type string


ASSIGN/V11=FORMAT("%X",INT(9567))
with this value: 255F

V12 becomes type string


ASSIGN/V12=FORMAT("%e",0.0005432) with this value: 5.432000e-
004

V13 becomes type string


ASSIGN/V13=FORMAT("%E",145.3421) with this value:
1.453421E+002

V14 becomes type string


ASSIGN/V14=FORMAT(",%6d,",INT(1))
with this value: , 1,

V15 becomes type string


ASSIGN/V15=FORMAT(",%-6d,",INT(1))
with this value: ,1 ,

GETSETTING

This function allows you to return various settings of PC-DMIS based on the string
parameter inserted.

GETSETTING(<String>)

You can use these string parameters:

• "DCC Mode" – Returns a 1 if PC-DMIS is in DCC mode, 0 otherwise.

45
Using Expressions and Variables

• "Manual Mode" – Returns a 1 if PC-DMIS is in Manual mode, 0 otherwise.


• "Current Alignment" – Returns a string of the current alignment.
• "Current Workplane" – Returns a string of the current workplane.
• "Workplane Value" – Returns a numerical value of the current workplane.
• "PreHit" – Returns the current prehit value as a double precision number.
• "Retract" – Returns the current retract value as a double precision
number.
• "Check" – Returns the current check value as a double precision number.
• "Touch Speed" – Returns the current Touch Speed value as a double
precision number.
• "Move Speed" – Returns the current Move Speed value as a double
precision number.
• "Fly Mode" – Returns a 1 if PC-DMIS uses the Fly Mode, 0 otherwise.
• "Ph9 present" – Returns a 1 if the Ph9/Ph10 is present, 0 otherwise.
• "Manual CMM" – Returns 1 if the CMM is a manual CMM, 0 otherwise.
• "LangStr(<Number or ID>)" – Returns a string from PC-DMIS's resources
in the current language from a resource ID number or from one of these
IDs:
"Yes", "No", "Oper", "Rept", "Input", "Doc", "YesNo", "Readout", "Internal",
"External", "Rect ", "Polr ", "Out", "In", "Least_Sqr", "Min_Sep",
"Max_Insc", "Min_CircSc", "Fixed_Rad", "Workplane", "Xaxis", "YAxis",
"ZAxis", "Xplus", "Xminus", "YPlus", "YMinus", "ZPlus", "ZMinus", "Point",
"Plane", "Line", "Circle", "Sphere", "Cylinder", "Round_Slot",
"Square_slot", "Cone", or "None".

If the value you use is a positive number, PC-DMIS pulls the string from its
resource.dll file. If you use a negative number, PC-DMIS pulls the string
from its strings.dll file (the strings table).
• "Extended Sheet Metal" – Returns a 1 if the Show Extended Sheet Metal
Options check box is selected inside the Setup Options dialog box, 0
otherwise.
• "LastHitMove(X)" – Returns the X value of the most recent HIT /BASIC or
MOVE/POINT command. PC-DMIS must be in DCC mode for this to work.
• "LastHitMove(Y)" – Returns the Y value of the most recent HIT/BASIC or
MOVE/POINT command. PC-DMIS must be in DCC mode for this
parameter to work.
• "LastHitMove(Z)" – Returns the Z value of the most recent HIT/BASIC or
MOVE/POINT command. PC-DMIS must be in DCC mode for this
parameter to work.

46
Understanding Expression Components

To determine whether PC-DMIS is in Manual or DCC mode, consider this example


of using the GETSETTING function:

ASSIGN/DCCMODEVAR=GETSETTING("DCC Mode") - This gives the


variable DCCMODEVAR the value of 1 if PC-DMIS is in DCC Mode, otherwise 0.

ASSIGN/MANMODEVAR=GETSETTING("Manual Mode") - This gives the


variable MANMODEVAR the value of 1 if PC-DMIS is in Manual Mode, otherwise
0.

To determine the current workplane, consider this example:

ASSIGN/WORKPLANE_ID=GETSETTING("Current Workplane") -
This gives the variable WORKPLANE_ID the string value of the current workplane
(ZPLUS, ZMINUS etc.).

ASSIGN/WORKPLANE_VALUE=GETSETTING("Workplane Value") - This


gives the variable WORKPLANE_VALUE a numerical value representing the
workplane. The workplanes have these values associated with them: ZPLUS = 0,
ZMINUS = 3, XPLUS = 1, XMINUS = 4, YPLUS = 2, or YMINUS = 5.

GETTEXT

This function returns the current text from the specified data field:
GETTEXT(<String or Integer>,<Integer>,<Pointer>)

This function has three fields.

First Field—Data Field Number or Description

The first field can be either a string description of the data field, indicated by item
(A) in the image below or the data field number, indicated in item (C) in the image
below.

47
Using Expressions and Variables

Item (B) in the image below is not used in this function, but is sometimes
used in automation or in report expressions.

To obtain these values:

1. Place PC-DMIS in Command Mode. Right-click anywhere in the Edit


window. A shortcut menu appears.
2. From the shortcut menu, select Change Pop-up Display and then Data
Type Information.
3. Position the mouse over a data field in the Edit window. The type
description, type number, and type index for that data item display.

The type description may be different for different languages. If your


measurement routine is executed on a version of PC-DMIS running in a different
language, use the type number instead.

Sample Data Type Information Showing (A) Type Description, (B) Type String
Identifier, (C) Type Number, and (D) Type Index

Second Field—Type Index

The second field is the type index, indicated as (D) in the above image. This field
is usually zero unless you have more instances of the same type of field in the
same command, such as multiple DIRECTORY fields shown in the above image.
The correct value for this field can be obtained in the same manner as described
for the first field.

48
Understanding Expression Components

Third Field—Command Pointer

The third field is a command pointer. It points to the command containing the field
from which the text is being obtained. This field can be specified either by using
command pointer notation (i.e., {F15}) or by using the GETCOMMAND expression
as shown in this example.

ASSIGN/V1=GETTEXT("Best Fit Math Type",0,{F15}) - This


command assigns V1 the current value of the best fit math type toggle of feature
F15.

ASSIGN/V2=GETCOMMAND("Comment","TOP",1) - V2 is assigned a pointer to


the first comment from the top of the measurement routine.

ASSIGN/V3=GETTEXT("Comment Type",1,V2) - V3 is assigned the value of


the Comment Type toggle field. If the first comment in the measurement routine is
a comment to be displayed to the operator, the value of V3 will be the string
"OPER".

See the "Pointer Functions" for information on the GETCOMMAND expression


used for setting a pointer to a command.

GETPROGRAMINFO

This function returns the measurement routine's information based on the


parameters passed in: GETPROGRAMINFO(<String>, <Optional String>)

This function has at most two strings as parameters. For most items, you only
need the first parameter. The string fields are not case sensitive.

First Field—String

The first field is a string input detailing what information to return.

DATE - Returns the current date

TIME - Returns the current time

PARTNAME - Returns the part name as defined in the measurement routine


header

PARTPATH - Returns the full pathway to the measurement routine file

49
Using Expressions and Variables

REVISION - Returns the revision number as defined in the heading

DRAWING - Like REVISION, this also returns the revision number as


defined in the heading

SERIALNUM - Returns the serial number as defined in the header

STATSCOUNT - Returns the current stats count

SEQNUM - Like STATSCOUNT, this string also returns the current stats
count number

SHRINK - Returns the global scale factor

NUMMEAS - Returns the number of dimensions executed

NUMOOT - Returns the number of out of tolerance dimensions executed

ELAPSEDTIME - Returns the time that has passed since the beginning of
the execution

FILENAME - Returns the measurement routine's file name (.prg)

CADMODELNAME - Returns the full path to the file name of the CAD model
that you imported into the measurement routine.

CADMODELFILENAME - Returns the name of only the CAD model (not the
path) that you imported into the measurement routine.

REPORTNAME - Returns the current output file name.

TEMP - Returns the temperature for the optional second input string. See
"Second Field—Optional String" below.

PRGVERSION - Returns a string value of the PC-DMIS version number of


the measurement routine file. You can save a measurement routine file to be
compatible with a specific version. For more information, see "Save As" in
the "Using Basic File Options" chapter.

PRGSCHEMA - Returns an integer of the PC-DMIS schema number of the


measurement routine file. This is an internal value used by PC-DMIS used to
indicate the commands and options that are serialized.

PCDMISVERSION - Returns a string value of the actual installed version of


the PC-DMIS software.

50
Understanding Expression Components

Second Field—Optional String

The second field is an optional string input. It's only needed if TEMP is used in the
in the first input field. The possible strings below come from the Temperature
Compensation command. For more information, see "Compensating For
Temperature" in the "Setting Your Preferences" chapter.

TEMPP - Returns the temperature for the part sensor

TEMPX - Returns the temperature for the X axis sensor

TEMPY - Returns the temperature for the Y axis sensor

TEMPZ - Returns the temperature for the Z axis sensor

REF_TEMP - Returns the reference temperature

HIGH_THRESHOLD - Returns the high threshold temperature

LOW_THRESHOLD - Returns the low threshold temperature

Example

$$ NO, This code sample displays the number of


total dimensions and the number of out-of-tolerance
dimensions.
ASSIGN/V1=GETPROGRAMINFO("NUMMEAS")
ASSIGN/V2=GETPROGRAMINFO("NUMOOT")
COMMENT/REPT
"Total Dimensions: "+V1
"Total Out of Tolerance: "+V2
$$ NO,This code sample returns the temperature on
the Z sensor axis.
ASSIGN/V3=GETPROGRAMINFO("TEMP", "TEMPZ")
COMMENT/REPT
"Temperature on the Z axis: "+V3

GETTRACEVALUE

Read Trace Value: GETTRACEVALUE(<string>)

51
Using Expressions and Variables

This function takes a single string parameter. It returns a value from a TRACEFIELD
command in the measurement routine.

<string> represents a case-sensitive string of the trace name whose value you want to
return.

If you have multiple trace fields with the same trace name, this function returns the
value for most recent trace field above this function. If a trace field doesn't contain a
value, this function returns a value of 0.

ASSIGN/V2=GETTRACEVALUE("Operator")

where "Operator" is the trace field name in the measurement routine.

INDEX

Substring Location: INDEX(<String>, <String>)

This function returns the location of the second string within the first string. The
first letter of string is 1. A return value of zero indicates that the sub string is not
found in the string.

For an example of this function, see the "Sample Code for Read Line" topic in the
"Using File Input / Output" chapter.

LASTEXECUTIONTIME

Formatted Last Execution Time: LASTEXECUTIONTIME()

This function returns the last execution time that PC-DMIS recorded and stored in
the <name of measurement routine>.MiniRoutines.xml file. The last execution time
appears in the Execution dialog box. The time is returned in "hh:mm:ss" format.

LEFT

Left number of characters of a string: LEFT(<String>, <n>)

This function returns a string consisting of a number of left-most characters


specified by the second expression (n) from the string specified in the first
expression (String).

The first expression (String) is coerced to type string. The second expression (n)
is coerced to type integer.

52
Understanding Expression Components

For an example of this function, see the "Sample Code for Read Line" topic in the
"Using File Input / Output" chapter.

LEN

Length of string: LEN(<String>)

This function returns the number of characters of the string.

LOWERCASE

Create lowercase string: LOWERCASE(<String>)

This function returns a string that is the lowercase equivalent of the expression
string.

MID

Middle n characters of a string: MID(<String>, <Integer>, <Optional Integer>)

This function returns a substring consisting of the characters of the string specified
in the first parameter starting at the position specified by the second parameter for
a length of n characters as specified by the third parameter. If the third parameter
is not supplied, the rest of the string is returned.

For an example of this function, see the "Sample Code for Read Line" topic in the
"Using File Input / Output" chapter.

ORD

Ordinal Conversion: ORD(<String>)

This function returns the integer ASCII value of first letter of the string (0-255).

PCDMISAPPLICATIONPATH

Full pathway display: PCDMISAPPLICATIONPPATH()

This function returns the string value containing the full path to the application
directory where PC-DMIS is installed. This directory contains the main executable
and other necessary program files to run PC-DMIS.

PCDMISUSERHIDDENDATAPATH

Full pathway display: PCDMISUSERHIDDENDATAPATH()

53
Using Expressions and Variables

This function returns the string value containing the full path of the hidden user
data directory used by PC-DMIS. See "Understanding File Locations" for the files
contained in this directory.

PCDMISUSERVISIBLEDATAPATH

Full pathway display: PCDMISUSERHIDDENDATAPATH()

This function returns the string value containing the full path of the visible user
data directory used by PC-DMIS. See "Understanding File Locations" for the files
contained in this directory.

PCDMISSYSTEMHIDDENDATAPATH

Full pathway display: PCDMISSYSTEMHIDDENDATAPATH()

This function returns the string value containing the full path of the hidden system
data directory used by PC-DMIS. See "Understanding File Locations" for the files
contained in this directory.

PCDMISSYSTEMVISIBLEDATAPATH

Full pathway display: PCDMISSYSTEMVISIBLEDATAPATH()

This function returns the string value containing the full path of the visible system
data directory used by PC-DMIS. See "Understanding File Locations" for the files
contained in this directory.

PCDMISSYSTEMREPORTINGPATH

Full pathway display: PCDMISSYSTEMREPORTINGPATH()

This function returns the string value containing the full path to the Reporting
directory used by PC-DMIS. This directory contains the report and label templates
used by the Report window.

RIGHT

Right n characters of string: RIGHT(<String>, <Integer>)

This function returns a string consisting of the n rightmost characters specified by


integer from the string.

SYSTEMDATE

System Date: SYSTEMDATE(<Date Format String>)

54
Understanding Expression Components

This function returns the date-formatted string with the current date details filled in.
For example, the command SYSTEMDATE("MM’/’dd’/’yy") returns the string
"02/12/14" if the current date is February 12, 2014.

Use the following string elements to create the date string. Elements must be in
the same case as shown below (MM instead of mm). Non-date characters (such
as spaces) that appear between date format string elements appear in the output
string in the same location as the input string. Characters in the input string
delimited by single quotes appear in the same location in the output string without
the single quotes.

d - Day of the month as digits. No leading zero for single-digit dates.

dd - Day of the month as digits. Leading zero used for single-digit dates.

ddd - Three-letter abbreviation for the day of the week.

dddd - Full name for the current day of the week.

M - Month as digits with no leading zeros for single-digit months.

MM - Month as digits with leading zero for single-digit months.

MMM - Month as three-letter abbreviation.

MMMM - Full name of month.

y - Year as digits with no leading zeros for single-digit years.

yy - Year as digits with leading zero for single-digit years.

yyyy - Year represented by four digits.

SYSTEMTIME

Formatted System Time: SYSTEMTIME(<Time Format String>)

This function returns the time-formatted string with the current time details filled in.
For example, the command SYSTEMTIME("hh:mm:ss tt") returns the time in a
formatted string, like this "11:29:40 PM".

Use the following string elements to create the time string. Elements must be in
the same case as shown below (tt instead of TT). Non-time characters (such as
spaces) appearing between time format string elements will appear in the output
string in the same location as the input string. Characters in the input string

55
Using Expressions and Variables

delimited by single quotes will appear in the same location in the output string
without the single quotes.

h - Hours with no leading zero for single-digit hours; 12-hour clock

hh - Hours with leading zero for single-digit hours; 12-hour clock

H - Hours with no leading zero for single-digit hours; 24-hour clock

HH - Hours with leading zero for single-digit hours; 24-hour clock

m - Minutes with no leading zero for single-digit minutes

mm - Minutes with leading zero for single-digit minutes

s - Seconds with no leading zero for single-digit seconds

ss - Seconds with leading zero for single-digit seconds

t - One character time marker string, such as A or P

tt - Multi-character time marker string, such as AM or PM

SYSTIME

System Time: SYSTIME()

This function returns a string with the current system time. This function differs
from the SYSTEMTIME function described above. It automatically returns the day,
date, and time, followed by the year.

Example: "Wed February 12 13:50:21 2014"

The returned string, showing the current system time, is adjusted to local
time zone settings.

UPPERCASE

Creates uppercase string: UPPERCASE(<String>)

This function returns a string that is the uppercase equivalent of string.

56
Understanding Expression Components

Mathematical Functions
ABS

Absolute Value: ABS(<Double>)


Returns the absolute value of the input.

EXP

Exponential: EXP(<Double>)
Returns the exponential of the expression.

LOG

Log Base 10: LOG(<Double>)


Returns the log base 10 of the expression.

LN

Natural Log: LN(<Double>)


Returns the natural logarithm of the expression.

ROUND

Rounding: ROUND(<Double>)
Returns the input rounded to the nearest integer.

SQRT

Square Root: SQRT(<Double>)


Returns the square root of the input.

Trigonometry Functions
By default, each of the trigonometry functions takes and returns radians. If you want
values in degrees, use the RAD2DEG function described below.

ACOS

ArcCosine: ACOS(<Double>)
Returns the arc cosine of the expression. For example, ACOS(5.0) returns 0. In general,
ACOS(<expression>) returns the arc cosine of the value of the expression.

57
Using Expressions and Variables

ASIN

ArcSine: ASIN(<Double>)
Returns the arc sine of the input.

ATAN

ArcTangent: ATAN(<Double>)
Returns the arc tangent of the input.

COS

Cosine: COS(<Double>)
Returns the cosine of the input.

DEG2RAD

Degrees to Radians: DEG2RAD(<Double>)


Returns the input divided by 360 and multiplied by 2π. This converts from degrees to
radians.

RAD2DEG

Radians to Degrees: RAD2DEG(<Double>)


Returns the input multiplied by 360 and divided by 2π. This converts from radians to
degrees.

SIN

Sine: SIN(<Double> )
Returns the sine of the input.

TAN

Tangent: TAN(<Double>)
Returns the tangent of the input.

Functions where the input is out of range (like ACOS, ASIN, LOG, LN, SQRT
and so on, that would cause the computer to crash) return 0.

58
Understanding Expression Components

Point Functions
ANGLEBETWEEN

Angle Between: ANGLEBETWEEN( <vector>, <vector>)

Returns the angle between the two vectors in degrees. The two parameters must be
expressions that evaluate to a vector type. To get the vector from a feature, for
example, you will need to use the feature ID followed by the .IJK extension. See the
example below:

F1 =GENERIC/POINT,DEPENDENT,CARTESIAN,$
NOM/XYZ,<3,3,3>,$
MEAS/XYZ,<3,3,3>,$
NOM/IJK,<1,0,0>,$
MEAS/IJK,<1,0,0>
F2 =GENERIC/POINT,DEPENDENT,CARTESIAN,$
NOM/XYZ,<10,10,10>,$
MEAS/XYZ,<10,10,10>,$
NOM/IJK,<0,0,1>,$
MEAS/IJK,<0,0,1>
ASSIGN/V1=F1.IJK
ASSIGN/V2=F2.IJK
ASSIGN/V3=ANGLEBETWEEN(V1,V2)
COMMENT/OPER,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
"The angle between "+V1+" and "+V2+" is: "+V3

CROSS

Cross Product: CROSS(<Point>, <Point>)

Return value is of type point and is the cross product of first and second expressions .

DELTA

Vector Offset: DELTA(<Point>, <Point>, <Double>)

The function takes the first expression (point) and calculates a new point in the direction
of the second expression (vector) at an offset of the third expression. For example,
DELTA(MPOINT(0,0,0),MPOINT(1,0,0),10) returns the point 10,0,0.

59
Using Expressions and Variables

DOT

Dot Product: DOT(<Point>, <Point>)

Returns the dot product of the two points (vectors).

UNIT

Unit Vector: UNIT(<Point>)

Returns the point divided by its length. For example, UNIT(MPOINT(0,0,0)) returns
the point 0,0,1.

MPOINT

Point Coercion: MPOINT(<Expression1>, <Expression2>, <Expression3>)

Coerces the three expressions to a type Point.

ASSIGN/V1=MPOINT(2.5,3.6,4)

V1.X has a value of 2.5


V1.Y has a value of 3.6
V1.Z has a value of 4.0

See "Point Coercion".

Pointer Functions
DIST2D

2d Distance: DIST2D(<FEAT1>, <FEAT2>, <FEAT3>)

The features must be inside curly braces.

This calculates the distance between the first two arguments in the command (Feat1
and Feat2), perpendicular to the third argument (Feat3).

60
Understanding Expression Components

• If the third argument is a plane, the distance between the first two
arguments is calculated perpendicular to the plane.
• If the third argument is a line or cylinder, the distance between the first two
arguments is calculated perpendicular to the third argument in the active
workplane.

For example, if you have the XY plane as your third argument, it will have a Z+ vector
(0,0,1) and the distance reported will only be in the Z axis.

Example
ASSIGN/V3=DIST2D({CIR1},{CIR2},{PLN1})
COMMENT/OPER,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
V3

DIST3D

3D Distance: DIST3D(<FEAT1>, <FEAT2>)

Calculates the 3D distance between Feat1 and Feat2.

The features must be inside curly braces.

Example
ASSIGN/V3=DIST3D({CIR1},{CIR2})
COMMENT/OPER,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
V3

GETCOMMAND

Obtains a pointer to the command specified by the


parameters: GETCOMMAND(<Integer or String>, <String>,<Integer>

First Parameter-Command Info Field

The first parameter is the command info field. It specifies the command type for
which to search. The following can be passed in:

• A command description string. See (A) in the graphic below.


• A command type number. See (B) in the graphic below.
• The unique number identifier. See (C) in the graphic below.

61
Using Expressions and Variables

If the unique id of the command is passed in, no other arguments are necessary.

To obtain the command description string, the command type number, and the
command’s unique number identifier:

1. Right-click in the Edit window


2. Choose Change Pop-up Display | Command Information (PC-DMIS
must be in Command Mode).
3. Position the mouse over the desired command. The command description,
type number, and unique number identifier for that command will be
displayed in the pop-up.

Sample Command Information Showing (A) Command Description String, (B)


Command Type Number, and (C) Unique Number Identifier (UID).

Second Parameter - Search Direction

The second parameter is the search direction. Legal values include:

Value Description
This value signifies the search should start at the current command and
UP
proceed upwards
This value signifies the search should start at the current command and
DOWN
proceed downwards.
This value signifies that the search should begin at the beginning of the
TOP
measurement routine in a downwards direction
This value signifies that the search should begin with the last object in
BOTTOM
the measurement routine in an upwards direction

Third Parameter - Which Instance to Find

The third parameter indicates which instance of the command should be found if
multiple instances of the same command are in the measurement routine.
62
Understanding Expression Components

If the measurement routine has two instances of a STATS/ON command


and you would like to obtain a pointer to the second instance from the top, "2"
would be passed in as the third parameter and "TOP" would be passed in as the
second parameter as shown here.

ASSIGN/V1=GETCOMMAND("Statistics","TOP",2)

The GETCOMMAND function can be used to supply the third parameter to the
GETTEXT string function. See "String Functions" for information on GETTEXT.

LEN

Pointer loop count: LEN(<POINTER>)

Returns the number of times a pointer has been in a loop. For example, if feature CIR1
is in a loop that iterates 10 times, you can store how many times CIR1 has been
measured in a variable, by using an ASSIGN statement like this:
ASSIGN/V1=LEN({CIR1})

Array Functions
ARRAY

Create Array: ARRAY(<EXPRESSION1>, <EXPRESSION2>, <EXPRESSION3>, …)


Creates an array object with the array elements indicated by the expression
parameters. The array elements are numbered with a base index of 1.

AVERAGE

Average array elements: AVERAGE(<ARRAY>)


Returns the average value of elements in the array.

EQUAL

Element by Element Array Comparison: EQUAL(<ARRAY>, <ARRAY>)


Compares the two arrays, element by element, to determine if the arrays hold the same
elements. If the two arrays are not the same size, or if any of the elements in one array
do not match the corresponding element in the other array, the function returns 0.
Otherwise, the function returns 1.

63
Using Expressions and Variables

LEN

Array element count: LEN(<ARRAY>)


Returns the number of elements in the array.

MAX

Largest array element: MAX(<ARRAY>)


Returns the largest element in the array. Items in the array are compared numerically or
alphabetically.

MIN

Smallest array element: MIN(<ARRAY>)


Returns the smallest element in the array. Items in the array are compared numerically
or alphabetically.

SUM

Sum array elements: SUM(<ARRAY>)

Returns the sum of elements in the array.

Miscellaneous Functions
ARCSEGMENTENDINDEX

This function returns the index number of the ending point of a specified arc segment
from a scan: ARCSEGMENTENDINDEX(<ID>, <index>,<tol1>,<tol2>)

<ID> - The first parameter is a string value of the ID of the scan on which this function
pulls out the index number of the ending point for the arc. This parameter can either be
the ID in quotation marks or any expression that when coerced to type string ends up
being the ID of a scan.

<index> - The second parameter is the index number for the arc from which you want to
get the ending point number. This is a one-based value. For example, the arc index
number would be 3 if you want the ending point number for the third arc in the scan.

<tol1> - The third parameter is the general feature tolerance. It is a maximum form error
used to break up the scan into lines and arcs.

64
Understanding Expression Components

<tol2> - The fourth parameter is the refine tolerance. Generally, this tighter tolerance is
used to drop points from either end of the feature until the form error of the segment is
within this tolerance.

Once you have the Start and End indices for an arc, you can use these points inside a
constructed feature to construct a separate arc feature. For a similar example, see
"Example of a Line Feature Created from a Scan Segment".

ARCSEGMENTSTARTINDEX

This function returns the index number of the starting point of a specified arc segment
from a scan: ARCSEGMENTSTARTINDEX(<ID>, <index>,<tol1>,<tol2>).

<ID> - The first parameter is a string value of the ID of the scan on which this function
pulls out the index number of the start point for the arc. This parameter can either be the
ID in quotation marks or any expression that when coerced to type string ends up being
the ID of a scan.

<index> - The second parameter is the index number for the arc from which you want to
get the start point number. This is a one-based value. For example, the arc index
number would be 3 if you want the start point number for the third arc in the scan.

<tol1> - The third parameter is the general feature tolerance. It is a maximum form error
used to break up the scan into lines and arcs.

<tol2> - The fourth parameter is the refine tolerance. Generally, this tighter tolerance is
used to drop points from either end of the feature until the form error of the segment is
within this tolerance.

There are two additional parameters, which control whether an identified arc segment in
a scan is acceptable. These can only be changed with the PC-DMIS Settings Editor.
Any arc segment with a radius less than the value for the
MinimumArcSegmentRadiusInMM registry entry is rejected. The default value for this
parameter is 2 mm. Similarly, any arc segment with a radius greater than the value for
the MaximumArcSegmentRadiusInMM registry entry is rejected. The default value for
this parameter is 2000 mm (it should not be necessary to change this value).

Once you have the Start and End indices for an arc, you can use these points inside a
constructed feature to construct a separate arc feature. For a similar example, see
"Example of a Line Feature Created from a Scan Segment".

EOF and EOL

For information on these functions, see "Checking for the End of a File or the End of a
Line" in the "Using File Input / Output" chapter.

65
Using Expressions and Variables

FUNCTION

Creates a function: FUNCTION((<PARAM1>, <PARAM2>…), <EXPRESSION>)

Creates a function that takes the number of parameters indicated by the parameter list
and substitutes those parameters into the expression.

• The first item when using the FUNCTION keyword is the parameter list.
• This list consists of parameter names separated by commas.
• The parameter list is also surrounded by parenthesis.
• The second item is the expression.
• The expression contains the parameter names where the parameters
should be substituted when the function is called.

For an example, see the "Generic Function Example" topic.

GETROTABDATA

This function returns the center, angular position, and vector values for the specified
rotary table.

GETROTABDATA(<PARAMETER>[,<TABLE>])

The function returns the values for the following configurations:

• Single rotary table


• Dual (independent) rotary tables
• Stacked rotary tables

The data that the function returns matches the data in the Rotary Table Setup dialog
box (Edit | Preferences | Rotary Table Setup). For more information about this dialog
box, see "Defining the Rotary Table".

CENTER

• "CENTER" - Returns the rotary table's current XYZ center.


• "CENTER","V" - Returns the current XYZ center for rotary table V in a dual-table
or stacked-table configuration.
• "CENTER","W" - Returns the current XYZ center for rotary table W in a dual-table
or stacked-table configuration.

Examples:

66
Understanding Expression Components

V1 is set to the rotary table's


ASSIGN/V1=GETROTABDATA("CENTER")
current XYZ center.

V1 is set to the current XYZ


ASSIGN/V1=GETROTABDATA("CENTER","V")
center for rotary table V.

V1 is set to the current XYZ


ASSIGN/V1=GETROTABDATA("CENTER","W")
center for rotary table W.

ANGULAR POSITION

• "ANGLE" - Returns the rotary table's current angular position.


• "ANGLE","V" - Returns the current angular position for rotary table V in a dual-
table or stacked-table configuration.
• "ANGLE","W" - Returns the current angular position for rotary table W in a dual-
table or stacked-table configuration.

Examples:

V2 is set to the rotary table's


ASSIGN/V2=GETROTABDATA("ANGLE")
current angular position.

V2 is set to the current angular


ASSIGN/V2=GETROTABDATA("ANGLE","V")
position for rotary table V.

V2 is set to the current angular


ASSIGN/V2=GETROTABDATA("ANGLE","W")
position for rotary table W.

VECTOR

• "VECTOR" - Returns the rotary table's current IJK vector.


• "VECTOR","V" - Returns the current IJK vector for rotary table V in a dual-table
or stacked-table configuration.
• "VECTOR","W" - Returns the current IJK vector for rotary table W a dual-table or
stacked-table configuration.

Examples:

V3 is set to the rotary table's


ASSIGN/V3=GETROTABDATA("VECTOR")
current IJK vector.

67
Using Expressions and Variables

V3 is set to the current IJK


ASSIGN/V3=GETROTABDATA("VECTOR","V")
vector for rotary table V.

V3 is set to the current IJK


ASSIGN/V3=GETROTABDATA("VECTOR","W")
vector for rotary table W.

The [TABLE] argument is optional. If you do not specify table V or W, PC-DMIS


does one of the following:

• If you are using a single-table or stacked-table configuration, it returns the values


for rotary table W.
• If you are using a dual-table configuration, it returns the values for the rotary
table that is activated on the Active Rotary Table toolbar. For more information
about the toolbar, see "Active Rotary Table Toolbar".

PC-DMIS has two internal table definitions to accommodate dual-table and stacked-
table configurations. For a single-table configuration, the second table definition is not
actually used. Because it does exist internally, an error will not occur if you specify table
V in a single-table configuration; however, this is not recommended. The values that the
function returns are not generally useful because the table does not actually exist.

IF

Conditional expression evaluation: IF(<EXPRESSION1>, <EXPRESSION2>,


<EXPRESSION3>)

If expression1 evaluates to true (non-zero), then this function returns the value of
expression2; otherwise, this function returns the value of expression3.

ISIOCHANNELSET

This expression takes two parameters. The first parameter indicates which I/O channel
will be checked (the range of numbers that is available is based on the machine being
used). The second parameter determines whether the software will query the Arm1 or
Arm2 machine. If the second parameter is set to 1 (one), it will query the Arm2
controller. If the second parameter is not present (or is set to zero), then the IO Channel
will query the Arm1 controller. The Arm1 controller is your only option if you are not in
multiple arm mode.

68
Understanding Expression Components

If an invalid probe data type, tip id, probe file name, or channel number
is supplied, the expression evaluates to 0.

Example:

V4 will equal 1 (evaluate to true) when the


ASSIGN/V4=ISIOCHANNELSET(3,0) channel is set, otherwise it will equal 0
(evaluate to false).

LINESEGMENTENDINDEX

This function returns the index number of the ending point of a specified line segment
from a scan: LINESEGMENTENDINDEX(<ID>, <index>,<tol1>,<tol2>).

<ID> - The first parameter is a string value of the ID of the scan on which this function
pulls out the index number of the ending point for the line segment. This parameter can
either be the ID in quotation marks or any expression that when coerced to type string
ends up being the ID of a scan.

<index> - The second parameter is the index number for the line segment from which
you want to get the end point number. This is a one-based value. For example, the line
segment index number would be 3 if you want the end point number for the third line in
the scan.

<tol1> - The third parameter is the general feature tolerance. It is a maximum form error
used to break up the scan into lines and arcs.

<tol2> - The fourth parameter is the refine tolerance. Generally, this tighter tolerance is
used to drop points from either end of the feature until the form error of the segment is
within this tolerance.

Once you have the Start and End indices for a line segment, you can use these points
inside a constructed feature to construct a separate line feature. For an example, see
"Example of a Line Feature Created from a Scan Segment".

LINESEGMENTSTARTINDEX

This returns the index number of the starting point of a specified line segment from a
scan: LINESEGMENTSTARTINDEX(<ID>, <index>,<tol1>,<tol2>).

69
Using Expressions and Variables

<ID> - The first parameter is a string value of the ID of the scan on which this function
pulls out the index number of the start point for the line segment. This can either be the
ID in quotation marks or any expression that when coerced to type string ends up being
the ID of a scan.

<index> - The second parameter is the index number for the line segment from which
you want to get the start point number. This is a one-based value. For example, the line
segment index number would be 3 if you want the start point number for the third line in
the scan.

<tol1> - The third parameter is the general feature tolerance. It is a maximum form error
used to break up the scan into lines and arcs.

<tol2> - The fourth parameter is the refine tolerance. Generally, this tighter tolerance is
used to drop points from either end of the feature until the form error of the segment is
within this tolerance.

There is an additional parameter that controls whether an identified line segment in a


scan is acceptable. This can only be changed with the PC-DMIS Settings Editor. Any
line segment of a length less than the value for the
MinimumLineSegmentLengthInMM registry entry is rejected. The default value for
this parameter is 2 mm.

Once you have the Start and End indices for a line segment, you can use these points
inside a constructed feature to construct a separate line feature. See "Example of a Line
Feature Created from a Scan Segment" for an example.

PROBEDATA

This function returns data about the current or specified probe


: PROBEDATA(<OPTPROBEDATATYPE>, <OPTTIPID>, <OPTPROBEFILENAME>)

This function takes up to three optional parameters. You only need to provide commas
between the parameters if you use more than one parameter. You do not need to use
commas between empty parameters. For example, to obtain the current probe's
diameter you would use ASSIGN/V1=PROBEDATA("DIAM").

OPTPROBEDATATYPE - Optional parameter which specifies what probe data the


expression should return. If this parameter is not supplied, the current tip ID is returned.
This parameter is of type string. Any expression that evaluates to a valid string
expression can be put in the first expression slot. Valid string expressions (not case
sensitive) for the first parameter include the following. These are string expressions and
should be inside double quotation marks:

"Offset" - Measured tip X,Y,Z offset. Returns type point.

70
Understanding Expression Components

"Vector" - Tip Vector. Returns type point.

"A" - Tip A Angle. Returns type double.

"B" - Tip B Angle. Returns type double.

"Diam" or "Diameter" - Measured tip diameter. The first four letters are
required "Diam", but could include more letters up to the full name of
"Diameter". Returns type double.

"Thick" or "Thickness" - Measured tip thickness. The first five letters are
required "Thick", but could include more letters up to the full name of
"Thickness". Returns type double.

"Date" - Date the tip was last qualified. Returns type string.

"Time" - Time the tip was last qualified. Returns type string.

"ID" - Tip ID. Default parameter. Returns type string.

"PrbRdv" - The probe's radial deviation. Returns type double.

"Standarddeviation" - The probe's standard deviation. Returns type double.

"C" - The C angle of a CW43 light probe head. Returns type integer.

Adding a "T" in front of "Offset", "Diameter", or "Thickness" returns the


theoretical information (for example, TOFFSET, TDIAMETER, and
TTHICKNESS).

OPTTIPID - This optional parameter specifies the tip to be used when obtaining the
probe data specified in the first expression. If not supplied, the current tip is used. This
parameter should be type string.

OPTPROBEFILENAME - This optional parameter specifies the probe filename to be


used in obtaining the probe data. If this is not supplied, the current probe file is used.

Examples:

V1 is set to
ASSIGN/V1=PROBEDATA() current tip id (i.e.
"T1A0B0")

71
Using Expressions and Variables

V2 is set to the
ASSIGN/V2=PROBEDATA("TOFFSET","T1A45B0") theoretical probe
offset for the tip
T1A45B0

V3 is set to a
string
representing the
ASSIGN/V3=PROBEDATA("Date","T1A90B90","MYPROB") date tip
T1A90B90of the
probe file
MYPROB was
last qualified.

SETROTABDATA

This function sets the center or vector to the new input value:
SETROTABDATA(<PARAMETER>,<NewValue>[,<TABLE>])
This function works in the following configurations:

• Single rotary table


• Dual (independent) rotary tables
• Stacked rotary tables

CENTER

• "CENTER",<NewValue> - Sets the rotary table's XYZ center to the new value.
• "CENTER",<NewValue>,"V" - Sets the XYZ center for rotary table V in a dual-
table or stacked-table configuration to the new value.
• "CENTER",<NewValue>,"W" - Sets the XYZ center for rotary table W in a dual-
table or stacked-table configuration to the new value.

Examples:

V1 is a return code
ASSIGN/V1=SETROTABDATA("CENTER",NewValue) (1=success,
0=failure).

V1 is a return code
ASSIGN/V1=SETROTABDATA("CENTER",NewValue,"V") (1=success,
0=failure).

72
Understanding Expression Components

V1 is a return code
ASSIGN/V1=SETROTABDATA("CENTER",NewValue,"W") (1=success,
0=failure).

VECTOR

• "VECTOR",<NewValue> - Sets the rotary table's IJK vector to the new value.
• "VECTOR",<NewValue>,"V" - Sets the IJK vector for rotary table V in a dual-
table or stacked-table configuration to the new value.
• "VECTOR",<NewValue>,"W" - Sets the IJK vector for rotary table W a dual-table
or stacked-table configuration to the new value.

Examples:

V2 is a return code
ASSIGN/V2=SETROTABDATA("VECTOR",NewValue) (1=success,
0=failure).

V2 is a return code
ASSIGN/V2=SETROTABDATA("VECTOR",NewValue,"V") (1=success,
0=failure).

V2 is a return code
ASSIGN/V2=SETROTABDATA("VECTOR",NewValue,"W") (1=success,
0=failure).

73
Using Expressions and Variables

The [TABLE] argument is optional. If you do not specify table V or W, PC-DMIS


does one of the following:

• If you are using a single-table or stacked-table configuration, it sets the new


value for rotary table W.
• If you are using a dual-table configuration, it sets the new value for the rotary
table that is activated on the Active Rotary Table toolbar. For more information
about the toolbar, see "Active Rotary Table Toolbar".

PC-DMIS has two internal table definitions to accommodate dual-table and stacked-
table configurations. For a single-table configuration, the second table definition is not
actually used. Because it does exist internally, an error will not occur if you specify table
V in a single-table configuration; however, this is not recommended. The values that the
function sets are not generally useful because the table does not actually exist.

TUTORELEMENT

This function takes one parameter, either a number or a string (a string would be the ID
of a feature).

TUTORELEMENT(<PARAMETER>)

This function works with the variable type, Structures. For explanations of structure and
sub-elements, see "Structures".

Examples:

Creates a single Tutor Element


ASSIGN/E=TUTORELEMENT(1)
Structure

For any number over 1, this creates


ASSIGN/WM=TUTORELEMENT(n) an array of n Tutor Element
Structures

Copies Data from feature CIR1 into


ASSIGN/CIR1E=TUTORELEMENT("CIR1")
the Tutor Element Structures.

The TutorElement structure currently has the following sub-elements:

Sub-Element Description

74
Understanding Expression Components

ID String of the Feature's ID


TYPE INTEGER (FTYPE)
X, Y, Z X, Y, and Z coordinate values
PR Polar Radius
PA Polar Angle
CX I
CY J
CZ K
DM Diameter 1
DM2 Diameter 2
DS Distance from the origin
A Angle
AXY Angle in the XY plane
AYZ Angle in the YZ plane
AZX Angle in the ZX plane
F Form Error
SDEV Standard Deviation
TP Position

QUALTOOLDATA

This function returns data about the current or specified calibration tool. It has this
syntax:

QUALTOOLDATA(<TOOLINFO>, <TOOLID>, <FACENUMBER>)

This function takes up to three parameters. It needs at least one parameter to return
any data:

The first parameter, <TOOLINFO>, is a string that specifies the type of information
to return about the calibration tool. If you don't pass this parameter, this function
returns the name of the current or specified calibration tool.

75
Using Expressions and Variables

• "CTE" or "COEFFICIENTOFTHERMALEXPANSION" - Either one of these strings


returns the coefficient of thermal expansion as a double value.
• "DIAM" - This string returns the diameter of the tool as a double value.
• "ID" - This string returns the name of the tool as a string value.
• "LENGTH" - This string acts the same as "DIAM". It also returns the diameter of the
tool as a double value.
• "OVERRIDEIJK" - This string returns the search override IJK vector as a point
value.
• "POLYDIAM" - This string returns the diameter of the specified polyhedral face as a
double value.
• "POLYIJK" - This string returns the IJK vector of the specified polyhedral face as a
point value.
• "POLYXYZ" - This string returns the XYZ center of the specified polyhedral face as
a point value.
• "SHANKIJK" - This string returns the IJK vector of the shank as a point value.
• "TYPE" - This string returns the type of tool as an integer value (0 for a sphere, 1 for
an Arm2 sphere, 2 for a polyhedral, 3 for an Arm2 polyhedral).
• "WIDTH" - This parameter is no longer used.
• "XYZ" - This string returns the XYZ location of the tool as a point value.

The second parameter, <TOOLID>, is a string that specifies the name for the
calibration tool for which you would like to receive information. If you don't pass this
parameter, PC-DMIS assumes you want information from the current calibration tool.
The string is not case sensitive.

The third parameter, <FACENUMBER>, is a parameter that you only need when you
work with a polyhedral calibration tool and only when the first parameter is
"POLYXYZ", "POLYIJK", or "POLYDIAM". This is an integer value that specifies the
face of the polyhedral tool to use in order to obtain data.

Examples:

ASSIGN/VDIAM=QUALTOOLDATA("DIAM Gives the variable VDIAM the diameter of


","SPHERE_1_IN") the tool SPHERE_1_IN.

Gives the variable VID the current tool's


ASSIGN/VID=QUALTOOLDATA("ID")
name.

ASSIGN/VTYPE=QUALTOOLDATA("TYPE Gives the variable VTYPE the current


") tool's type.

Gives the variable VPOLYDIAM the


ASSIGN/VPOLYDIAM=QUALTOOLDATA("
diameter of face 3 on the polyhedral tool,

76
Understanding Expression Components

POLYDIAM","POLYTEST",3) POLYTEST.

Function Examples
Below are some different examples of functions that may help you in creating and using
your own functions:

• Generic Function Example


• Functions Passed as Variables Example
• Function with Multiple Parameters Example
• Functions Creating Other Functions Example
• Functions As Members of an Array Example
• Functions Defined Recursively Example

Generic Function Example

ASSIGN/MYFUNC=FUNCTION((X,Y,Z),X*3+Y*2+Z)
Creates a user-defined function and assigns it to the variable MYFUNC. The function
takes three parameters, X,Y, and Z.

X is multiplied by 3.

Y is multiplied by 2.

Z holds the passed value.

The total of X + Y + Z is what gets returned when values are passed into the function,
as shown here:

ASSIGN/V1=MYFUNC(7,2,5)
This assigns V1 the value 30 by evaluating the parameters passed into the function
MYFUNC(7,2,5). 7 is the parameter and is substituted where X occurs in the expression
portion of the function definition. Thus, X*3 becomes 7*3, or 21.

2 is substituted where Y occurs. Thus Y*2 becomes 2*2, or 4.

5 is substituted where Z occurs.

77
Using Expressions and Variables

The values are then all added together (21 + 4 + 5) and passed to V1.

Functions Passed as Variables Example

Functions can be passed as variables. The following example builds on the Generic
Function Example above:

ASSIGN/NEWFUNC=MYFUNC
Sets the variable NEWFUNC to have the same function that MYFUNC has.

ASSIGN/V3=NEWFUNC(12,2,3)
Assigns V3 to have the value 43 from the evaluated expressions within the function (36
+ 4 + 3).

Function with Multiple Parameters Example

Functions can have multiple parameters:

ASSIGN/ADDANDDOUBLE=FUNCTION((A,B),2*(A+B))
Creates a function and assigns it to the function ADDANDDOUBLE. The function takes
two parameters, adds them together and then multiplies the result by 2.

ASSIGN/V2=ADDANDDOUBLE(4,5)
Assigns V2 the value 18. The parameters 4 and 5 are substituted into the expression
portion of the function, thus becoming 2*(4+5).

Functions Creating Other Functions Example

Functions can create other functions.

ASSIGN/COMPOSE=FUNCTION((F,G),FUNCTION((X),G(F(X))))
Assigns COMPOSE to be a function that takes two functions as parameters and creates
a new function using the two functions.

ASSIGN/ADD2=FUNCTION((X),X+2)
Assigns ADD2 to be a function that adds two to the parameter passed in.

ASSIGN/ADD3=FUNCTION((X),X+3)
Assigns ADD3 to be a function that adds three to the parameter passed in.

ASSIGN/ADD5=COMPOSE(ADD2,ADD3)
Assigns ADD5 to be a function composed of the functions ADD2 and ADD3.

78
Understanding Expression Components

ASSIGN/V5=ADD5(3)
Assigns V5 to have the value V8.

Functions As Members of an Array Example

Functions can be members of an array.

ASSIGN/ANARRAY=ARRAY(3,FACTORIAL,"Hello World",ADD5)
Assigns ANARRAY to be an array of 4 elements : a number (3), a function
(FACTORIAL), a string, ("Hello World"), and a function (Add5).

ASSIGN/V6=ANARRAY[2](4)
The second element of ANARRAY is the function FACTORIAL. The parameter 4 is
passed in to this function and the result of 24 is assigned to V6.

ASSIGN/V7=ANARRAY[2](ANARRAY[4](ANARRAY[1]))
From the inside out: The first element of ANARRAY (3) is passed to the function of the
fourth array element (Add5). The result, 8, is passed to the function of the second array
element (FACTORIAL) and assigned to V7. V7 receives a value of 40320.

Functions Defined Recursively Example

Functions can be defined recursively, meaning they can be defined to call themselves.

ASSIGN/FACTORIAL=FUNCTION((X),IF(X<=1,1,X*FACTORIAL(X-1))
Creates a function called factorial that takes one parameter. If the parameter is less
than or equal to 1 it evaluates to 1, otherwise it evaluates to X multiplied by the
FACTORIAL of X-1.

ASSIGN/V4=FACTORIAL(5)
Assigns V4 the value of 120 (5*4*3*2*1).

Example of a Line Feature Created from a Scan Segment


This topic provides an example of how to use PC-DMIS expression language,
specifically the line segment functions, to export start and end point numbers for line
segments within a scan and then to create your own line feature by using the extracted
points within a constructed feature. You can use the same principles covered in this
example to create an arc segment from a scan as well.

Suppose your measurement routine has a scan feature named SCN1 that looks like
this:

79
Using Expressions and Variables

SCN1=FEAT/SCAN,LINEAROPEN,SHOW HITS=NO,SHOWALLPARAMS=YES
EXEC MODE=RELEARN, NOMS MODE=FIND NOMS,CLEARPLANE=NO,SINGLE
POINT=NO,THICKNESS=0
FINDNOMS=5,SELECTEDONLY=NO,USEBESTFIT=NO,PROBECOMP=YES,AVOID
ANCE MOVE=NO,DISTANCE=0,CAD Compensation=NO
DIR1=VARIABLE,
HITTYPE=VECTOR
INITVEC=0,-1,0
DIRVEC=1,0,0
CUTVEC=0,0,1
ENDVEC=0,-1,0
PLANEVEC=-1,0,0
POINT1=100,0,-5
POINT2=70,0,-5
MEAS/SCAN
BASICSCAN/LINE,SHOW HITS=NO,SHOWALLPARAMS=YES
<100,0,-5>,<70,0,-5>,CutVec=0,0,1,DirVec=1,0,0
InitVec=0,-1,0,EndVec=0,-1,0,THICKNESS=0
FILTER/NULLFILTER,
EXEC MODE=RELEARN
BOUNDARY/PLANE,<70,0,-5>,PlaneVec=-1,0,0,Crossings=2
HITTYPE/VECTOR
NOMS MODE=FINDNOMS,5
ENDSCAN
ENDMEAS/

To create a line from this scan you will need to use the LINESEGMENTSTARTINDEX
and LINESEGMENTENDINDEX functions to pull out the data, like this:

ASSIGN/LINESTARTINDEX=LINESEGMENTSTARTINDEX("SCN1",1,0.4,0.1
)
ASSIGN/LINEENDINDEX=LINESEGMENTENDINDEX("SCN1",1,0.4, 0.1)

This tells PC-DMIS to go to the scan named "SCN1", and from its first line segment pull
out the starting and ending index values that fall within the defined tolerances. It then
assigns those index values to variables named LINESTARTINDEX and
LINEENDINDEX.

80
Understanding Expression Components

Once you have the start and ending index values for the line segment assigned to
variables, you can use those variables within a constructed line, like this:

LIN4=FEAT/LINE,RECT,UNBND
THEO/100.225,0,-5.011,1,0,0
ACTL/100.225,-0.005,-5.011,1,-0.0000388,0
CONSTR/LINE,BF,2D,SCN1.HIT[LINESTARTINDEX..LINEENDINDEX],,
OUTLIER_REMOVAL/OFF,3
FILTER/OFF,WAVELENGTH=0

Notice that in the highlighted code from the line feature above, PC-DMIS uses the
starting and ending numbers you pulled out of the scan to create the feature:
SCN1.HIT[LINESTARTINDEX..LINEENDINDEX]

Operand Coercion
Operands can be coerced to other types using any of the coercion operators:

Integer Coercion
INT(<Expression>) - Coerces value of expression to type integer.

INT(4) Evaluates to 4

INT(4.5) Evaluates to 4

INT("Hello World") Evaluates to 0

INT("2") Evaluates to 2

INT("2.2") Evaluates 2

INT("3 Blind Mice") Evaluates to 3

INT("The 3 Blind
Evaluates to 0
Mice")

INT("3, 4, 5") Evaluates to 3

Evaluates to the distance of the point from the origin, in


INT(MPOINT(0, 0, 1))
this case 1

81
Using Expressions and Variables

Distance evaluates to 7.0711, this expression evaluates to


INT(MPOINT(3, 4, 5))
7

Double Coercion
DOUBLE(<Expression>) - Coerces value of expression to type double

DOUBLE(4) Evaluates to 4.0

DOUBLE(4.5) Evaluates to 4.5

DOUBLE("A String") Evaluates to 0.0

DOUBLE("3.5") Evaluates to 3.5

DOUBLE("3.5 inches") Evaluates to 3.5

DOUBLE("The circle measures 3.5 inches in


Evaluates to 0.0
diameter ")

DOUBLE(MPOINT(0,0,1)) Evaluates to 1.0

Evaluates to
DOUBLE(MPOINT(3,4,5))
7.0711

String Coercion
STR(<Expression>) - Coerces value of expression to type string

STR(4) Evaluates to "4"

STR(4.5) Evaluates to "4.5"

STR("Hello World") Evaluates to "Hello World"

STR(MPOINT(3,4,5)) Evaluates to "3, 4, 5"

82
Understanding Expression Components

Point Coercion
MPOINT(<Expression1>, <Expression2>, <Expression3>) - Coerces values of
expressions to type point after coercing each expression to type double.

MPOINT( 1, 1, 1) Evaluates to point 1.0,1.0,1.0

MPOINT( 1.1, 1.1, 1.1) Evaluates to point 1.1, 1.1, 1.1

MPOINT("1", "1", "1") Evaluates to point 1.0,1.0,1.0

MPOINT( 3, 4.5, "5.6") Evaluates to point 3.0, 4.5, 5.6

MPOINT( MPOINT(1, 0, 0),


MPOINT(0,1,0), Evaluates to 1.0, 1.0, 7.0711
MPOINT(3,4,5) )

Operand Coercion and Mixed Type Expressions


The expression evaluator automatically coerces variables in mixed-type expressions. If
the result of an expression is not what is expected because of automatic coercion, use
of the coercion operators in some cases yields the desired result. Following are
examples of automatic coercions in mixed-type expressions.

"CIR" + 1
Evaluates to "CIR1"

"2" + 2
Evaluates to 4

"The Value of 2+2 is " + 2 + 2


Evaluates to "The Value of 2+2 is 22" (Since expressions are evaluated left to right)

"The Value of 2+2 is " + (2 + 2)


Evaluates to "The Value of 2+2 is 4"

LINE1.XYZ > 2
Evaluates to 1 if the distance of the centroid of LINE1 from the origin is greater than 2

LINE1.XYZ > LINE2.XYZ


Evaluates to 1 if the centroid of LINE1 is further from the origin than the centroid of
LINE2

83
Using Expressions and Variables

LINE1.XYZ = LINE2.XYZ
Evaluates to 1 if the centroids of LINE1 and LINE2 are the same (no coercion occurs in
this case)

DOUBLE(LINE1.XYZ) = DOUBLE(LINE2.XYZ)
Evaluates to 1 if the centroids are the same distance from the origin

11% 3.1
Evaluates to 2 (% is the modulo operator designed to work with integers. It returns the
remainder from discrete division. 11%3 = 2.)

CIRCLE1.HIT [3.2].X
Evaluates to measured X value of third hit of Circle1. The argument 3.2 is automatically
coerced to an integer with a value of 3.

ID Expressions
Many of the PC-DMIS commands use feature IDs as parameters. For example,
constructed features use IDs to indicate which features are to be used as inputs for the
constructed feature. ID expressions allow the user to refer to a specific instance of a
feature, a group of similarly named features, an instance of a feature inside a call to a
subroutine, or a feature in an external measurement routine.

Feature Array ID
Use a feature array id to refer to a specific instance of a feature or to a range of feature
instances. For example, if the feature "Circle1" were located in a while loop that looped
five times, then five instances of the circle would exist upon exiting the loop. To refer to
an individual instance of the five instances of "Circle1", use feature array syntax as
described under "Feature Arrays:" where "Circle1[1]" would refer to the first instance,
"Circle1[2]" would refer to the second instance, etc.

To refer to a range of instances use the .. notation. "Circle1[1..3]" refers to the 1st
through 3rd instances of Circle1. "Circle1[3..5] refers to the 3rd through 5th instances of
Circle1. "Circle1[1..5]" would refer to the 1st through 5th instances of Circle1. When a
range of feature is referred to, the set is treated and behaves as a constructed set.

ID Wild Cards
Use ID Wild Cards to refer to a set of similarly named features. The two wild card
characters are "*" and "?". (See "Selecting Features Using Meta-character matching" in
the "Editing the CAD Display" chapter for additional information.)
84
Understanding Expression Components

The asterisk ‘*’ character refers to 0 or more instances of any character. To refer to the
set of all feature that start with the letters "CIR", use the expression ID "CIR*". This
syntax creates a set of features that include all features with Ids that start with "CIR",
such as "CIRCLE1", "CIRCLE2", "CIR3", or "CIR".

If CIR3 has several executions only the most recent measurement is used. To
get the different instances of the executions, the following expression could be used:
CIR?[1..3]

The question mark ‘?’ character refers to a single instance of any character.

The ID expression "MY???1" would create a set of features that are six
characters long, begin with "MY" and end with "1", such as "MYCIR1", "MYCON1",
"MYLIN1", or "MYFT21".

IDs for Features Within Subroutines, Basic Scripts, or


External Routines
Subroutines can be located within the current measurement routine or in an external
measurement routine. When the subroutine is located in the same routine as the call to
the subroutine, you can use the feature array ID syntax explained under "Feature
Arrays:" to refer to individual instances of a feature created in the subroutine. However,
when the subroutine is located in an external measurement routine, you can use the
following syntax o refer to any features created in the subroutine: "<Call Sub
ID>:<FeatID>".

For example, if a feature named "F1" were located in an external subroutine that was
called from a Call Sub command with the id "CS1", then the ID expression "CS1:F1"
could be used to refer to that feature.

85
Using Expressions and Variables

This example merely illustrates the use of the syntax CS1.F1 and is not
intended to use.

Routine 1: PLUS1.PRG

SUBROUTINE/PLUS1, A1 = 0, A2 = 0, A3 = 0
F1 =FEAT/POINT,RECT
THEO /A1+1,A2+1,A3+1,0,0,1
ACTL/3,1,1,0,0,1
MEAS/POINT,1
HIT /BASIC,A1+1,A2+1,A3+1,0,0,1,0,0,0
ENDMEAS/
ENDSUB/

Routine 2: TEST.PRG

CS1 =CALLSUB/PLUS1,D:\V30\WINDEBUG\PLUS1.PRG: 3,3,3,,


DIM D1= LOCATION OF POINT CS1:F1 UNITS=IN,$
GRAPH=OFF TEXT=OFF MULT=10.00 OUTPUT=BOTH
AX NOMINAL +TOL -TOL MEAS MAX MIN DEV OUTTOL
X 3.0000 0.0000 0.0000 3.0000 3.0000 3.0000 0.0000 0.0000
----#----
END OF DIMENSION D1

Basic scripts create and delete objects dynamically. Use the syntax "<Basic Script
ID>:<Feat ID>" to refer to a feature created by a basic script. For example, if a basic
script with ID "BS1" creates a feature with ID "F2", use the ID expression "BS1:F2" to
refer to that feature.

You can use the attach command to attach external routines to PC-DMIS. To refer to
features in the attached routine use the following syntax: "<Attach Routine ID>:<Feat
ID>". To refer to feature "F3" in the attached measurement routine with ID "GEAR1",
use the expression, "GEAR1:F3". (See "Attaching an External Measurement Routine" in
the "Adding External Elements" chapter for more information.)

ID Expression Combinations
You can use array ID Expressions, Wild Card ID Expressions, and external subroutine,
basic script, and external measurement routine ID Expressions in combination. For
example, to refer to the third instance of all features that start with the letters "CIR" in an

86
Accessing a Report's Object Properties

external measurement routine attached with the ID "BOLTPAT", use the ID expression
"BOLTPAT:CIR*[3]".

Also, you can use ID Expressions in regular expressions. Thus, the measured centroid
of the above set of features could be assigned to variable with the following expression:

ASSIGN/V1=BOLTPAT:CIR*[3].XYZ

Also, ID Expressions can be used in regular expressions. Thus, the measured centroid
of the above set of features could be assigned to variable with the following expression:

ASSIGN/V1=BOLTPAT:CIR*[3].XYZ

Accessing a Report's Object Properties


You can create your own custom report and label templates. PC-DMIS uses them to
display report data inside a Report window (see View | Report Window). You use
template editors to create the templates. The editors utilize a Visual Basic-like interface
that you can use to insert, relocate, and size special components called "objects".

Each object consists of "properties" that define how it appears and what information it
holds. Some of these properties are common to all other objects, some are common to
only related objects, and others are unique to that specific object.

The PC-DMIS Expression Language can query the currently loaded report and store
property values of a particular object in a variable. It can obtain values of type String,
Integer, and Real by using this syntax:

Property Query Syntax


ASSIGN/V1=Report.<Object Name>.<Property Name>

Report is a reference to the currently loaded report. <Object Name> is the object's
unique name. <Property Name> is a valid property name for that object.

87
Using Expressions and Variables

Example

Suppose that your report template has a text object called "Text1" that you
want to use in the final report to display the operator's name. The actual string of
characters that represent the operator's name will be stored in the Text property of the
object. By default, the text property (displayed text) initially has the value of "Text1" (see
the figure below). Because this is a user-assigned property, this will change when you
type in the name during execution.

Properties dialog box that shows a selected object and the property to query

To use the Expression Language code to query this Text object's "Text" property and
obtain the keyed-in data, you would use the following command:

ASSIGN/V1=Report.Text1.Text

In this code:

"Report" tells the code to look at the report loaded in the Report window.

"Text1" tells it to look for the object named "Text1".

"Text" tells it to look for the "Text" property within that object. The value of the
"Text" property then gets passed into the V1 variable, which you could then
further manipulate or display using the PC-DMIS Expression Language.

Finding Properties

To find the properties that are associated with a particular object, access the Report
template in the Report template editor (File | Reporting | Edit | Report Template),
select the object, and then right-click on the object to display its property sheet.

88
Accessing a Report's Object Properties

Property sheet for a Text object

The property sheet contains two columns. The left column displays the property name.
The right column displays the current value. Be sure to use the exact property name in
your expression code.

89
Using Expressions and Variables

When you query property values, you may find that some properties return a
seemingly useless numerical value. Generally, this happens when the property has a
set list of available options. PC-DMIS returns an internal value for the selected property
that does not relate to the displayed property.

For example, the Text object has an Orientation property with these values:

• 0 - Horizontal
• 1 - Vertical up
• 2 - Vertical down

However, if you obtain the value using PC-DMIS expression language, the software will
instead return the following:

• 0 (for Horizontal)
• 900 (for Vertical up)
• -900 (for Vertical down)

It may require some trial and error to determine what returned values correspond with
the value displayed on the property sheet.

Accessing Information from a


Constructed Scan Minimum Circle
You can use PC-DMIS expressions to pull information from a circle feature that is
constructed with a given radius at a minimum point along a linear scan. See the
"Constructing a Circle at a Scan's Minimum Point" topic in the "Constructing New
Features from Existing Features" chapter for more information.

When you construct a scan minimum circle feature, the circle ultimately uses a vector
(termed the down vector) to contact the scan line. It only contacts the line in two places
called contact points (CONTACTPOINT1 and CONTACTPOINT2). PC-DMIS can then
use these points to determine the angles from the down vector to these contact points
(CONTACTANGLE1 and CONTACTANGLE2). For example, consider this diagram:

90
Accessing Information from a Constructed Scan Minimum Circle

A - The scan line to which the circle is constructed.

B - The final XYZ position of the circle's centroid.

C - The contact point to the left of the Down Vector. It is termed CONTACTPOINT1.

D - The contact point to the right of the Down Vector. It is termed CONTACTPOINT2.

E - The Down Vector.

F - The angle from the Down Vector to CONTACTPOINT1. It is termed


CONTACTANGLE1.

G - The angle from the Down Vector to the CONTACTPOINT2. It is termed


CONTACTANGLE2.

The expressions detailed below will only function with this type of constructed circle
feature. You can also use CONTACTPOINT2 in the syntax below to return the
equivalent information using the second contact point instead.

ASSIGN/V1=CIR1.CONTACTPOINT1.XYZ
Returns the XYZ point information for the circle's first contact point with the line,
CONTACTPOINT1.

ASSIGN/V1=CIR1.CONTACTPOINT1.X
Returns the X information for CONTACTPOINT1.

91
Using Expressions and Variables

ASSIGN/V1=CIR1.CONTACTPOINT1.Y
Returns the Y information for CONTACTPOINT1.

ASSIGN/V1=CIR1.CONTACTPOINT1.Z
Returns the Z information for CONTACTPOINT1.

ASSIGN/V1=CIR1.CONTACTPOINT1.IJK
Returns the IJK vector from CONTACTPOINT1 to the circle's centroid.

ASSIGN/V1=CIR1.CONTACTPOINT1.I
Returns the I value from the above CONTACTPOINT1 IJK vector.

ASSIGN/V1=CIR1.CONTACTPOINT1.J
Returns the J value from the above CONTACTPOINT1 IJK vector.

ASSIGN/V1=CIR1.CONTACTPOINT1.K
Returns the K value from the above CONTACTPOINT1 IJK vector.

ASSIGN/V1=CIR1.CONTACTANGLE1
Returns the angle from the Down Vector to CONTACTPOINT1.

ASSIGN/V1=CIR1.CONTACTANGLE2
Returns the angle from the Down Vector to CONTACTPOINT2.

ASSIGN/V1=CIR1.CONTACTANGLE
Returns the sum of the absolute values of CONTACTANGLE1 and CONTACTANGLE2.
It should be no greater than 180 degrees.

92

You might also like