Since [ and ] are now special characters, for them to be output in the NC code, you would have to enter them as <91> and <93>, respectively. When opening an existing CNC file that contains the characters, they will be automatically converted to <91> and <93>.
XBuild accepts the following numeric operators:
|
+ |
|
|
acosd |
Computes the arccosine (in degrees) of a number. |
|
- |
subtraction, subtracts two numbers |
|
atand |
Computes the arctangent (in degrees) of a number. |
|
* |
multiplication, multiplies two numbers |
|
atan2d |
Computes the arctangent (in degrees) of a number. |
|
/ |
division, divides two numbers |
|
ceil(num) |
returns the nearest integer greater than or equal to a number. |
|
sin |
Computes the sine of an angle (given in radians). |
|
floor(num) |
Returns the nearest integer less than or equal to a number. |
|
cos |
Computes the cosine of an angle (given in radians). |
|
fabs(num) |
Returns the absolute value of a number. |
|
tan |
Computes the tangent of an angle (given in radians). |
|
sqrt(num) |
Returns the square root of a number. |
|
sind |
Computes the sine of an angle (given in degrees). |
|
mm2in
|
Converts from milliliters to inches. |
|
cosd |
Computes the cosine of an angle (given in degrees). |
|
exp(num) |
Returns e^x where e = 2.71828. |
|
tand |
Computes the tangent of an angle (given in degrees). |
|
log(num) |
Returns ln(x) where ln is the natural logarithm. |
|
asin |
Computes the arcsine (in radians) of a number. |
|
log10 |
Returns the base-10 logarithm of a number. |
|
acos |
Computes the arccosine (in radians) of a number. |
|
pow(base, power) |
Returns a base number raised to a power. |
|
atan |
Computes the arctangent (in radians) of a number. |
|
degtorad |
Returns an angle in radians as converted from degrees |
|
atan2 |
Computes the arctangent (in radians) of a number. |
|
radtodeg |
Returns an angle in degrees as converted from radians |
|
asind |
Computes the arcsine (in degrees) of a number. |
|
pi |
The mathematical value of pi to ten decimal places. |
|
|
|
|
|
|
|
in2mm (num) |
Converts inches to millimeters. |
|
radiusxy(x,y) |
Computes the distance from the origin to (XY) |
|
|
|
|
|
|
|
anglexy(x,y) |
Computes the angle between the X-axis to the line between (0,0) and (x,y) |
|
|
|
|
Operator |
Function |
Example |
Explanation |
|
eq |
Equal |
[eq(<TOOL>, 0)] |
True if <TOOL> Ί 0 Also works for strings. |
|
neq |
Not Equal |
[neq(<TOOL>, 0)] |
True if <TOOL> Ή 0 Also works for strings. |
|
lt |
Less Than |
[lt(<TOOL>, 0)] |
True if <TOOL> < 0 Also works for strings. |
|
gt |
Greater Than |
[gt(<TOOL>, 0)] |
True if <TOOL> > 0 Also works for strings. |
|
le |
Less Than or Equal |
[le(<TOOL>, 0)] |
True if <TOOL> £ 0 Also works for strings. |
|
ge |
Greater Than or Equal |
[ge(<TOOL>, 0)] |
True if <TOOL> ³ 0 Also works for strings. |
|
and |
And |
[and(<Z-UP>, <INDEX>)] |
True if both <Z UP> and <INDEX> are true |
|
or |
Or |
[or(<Z-UP>, <INDEX>)] |
True if either <Z UP> or <INDEX> is true |
|
not |
Not |
[not(<Z-CHANGED>)] |
True if <Z CHANGE> is false |
|
apxeq |
Approximately Equal (if tolerance is not given, the default is 1e-6.) |
[apxeq(<Z-COORD>, 0)] [apxeq(<Z-COORD>, 0, 1e-6)] |
True if <Z COORD> Ί 0 within ± 1e-6 |
Some example expressions using operators are:
Output Z as 0 if Z is within 0.0001 of zero.
<IF>[apxeq(<Z-COORD>, 0 , 0.0001)]<THEN>
N<SEQ> G00 X<X-COORD> Y<Y-COORD> Z0<EOB>
<ENDIF>
Rapid move using polar coordinates.
N<SEQ> I0 J0<EOB>
N<SEQ> G10 R[sqrt(pow(<X-COORD>, 2) + pow(<Y-COORD>, 2))]
H[D|3.2|1.0:atan2d(<Y-COORD>, <X-COORD>)]<EOB>
Output Z as 15 if Z is between 10 and 20 inclusively
<IF>[and(ge(<Z-COORD>, 10), le(<Z-COORD>, 20))] <THEN>
N<SEQ> G00 X<X-COORD> Y<Y-COORD> Z15<EOB>
<ENDIF>
If the P variable, P1, is not set, then set it to the string, G0
<IF>[eq(<P1>,"")]<THEN>
[<P1>=G0]
<ENDIF>
|
Operator |
Function |
Example |
Explanation |
|
uppercase |
Convert string to all uppercase characters |
[uppercase(abc)] |
Prints ABC
|
|
+ |
If used with two strings, the strings are concatenated. |
[abc + def] |
Prints abcdef |
|
+ |
If used with a string and a number the number is converted to a string and then they are added. |
[0.5 +0.0] |
Prints 0.5 This is a shortcut for converting a string into a number. |
Many of the logical operators also work for strings.
The result of any operation can be assigned to another keyword or to a variable. Variable names can consist of one more characters and are not case sensitive. The first character must be alphabetic and the rest can be any combination of alphanumeric characters and the underscore character. Examples of variables are: ABC, X23, and CENTER_PT.
Note that the result of an assignment operation is the value of the keyword or variable being assigned. For example the result is 5 for [x = 5]. Strings can contain numeric, logical and string values.
Examples of assignment and variable usage are:
Increase the current value of the keyword <Z-COORD> by ten.
[<Z-COORD> = <Z-COORD> + 10]
Set the variable, XVAR, to the current value of <X-COORD>, then double XVAR. Note that these statements do not change the value of <X-COORD>
[x_var = <X-COORD>]
[x_var = x_var * 2]
3. Set the variable, FEATURE, to the string, hole, then add the string, top to the variable, FEATURE, and set the new string to the variable, NAME.
[feature=hole]
[name= top + feature]
The format for an expression can be customized by preceding the expression with an optional format specification. The format specification is separated from the expression by a :.
|
LTDUP|Format|Factor |
Where: L stands for leading zeros T stands for trailing zeros D stands for decimal point U stands for unsigned value P stands for plus sign Format specifies the number of digits (e.g. 3.4) Factor specifies the multiplier (e.g. 1.0) |
The above form is in correspondence with the Words Info dialog in XBuild..
The following examples illustrate types of formatting.
|
Expression |
Result |
|
[D|3.4|1.0:10] |
10.0 |
|
[D|5.4|1.0:10] |
10.0 |
|
[LD|3.4|1.0:10] |
010.0 |
|
[LP|3.0|1.0:10] |
+010 |
|
[PT|3.1|1.0:10] |
+100 |
When no format specification is given and there is no colon specified, we automatically use the format of the numeric keyword within the square brackets. For example [<X-COORD>+1] is printed in the default format for the <X-COORD> keyword that is specified in the Words 1 Words4 dialog boxes. If there is no such keyword, such as in the expression [1+2], the default format for the keyword <Z-COORD>s format is used.
To suppress the printing of the assignment result, specify only the colon as the format specification. Neither of the following expressions will print a value because the first character of the expression:
[:x_var=<X-COORD>+1]
[:<Y-COORD>*2]
[# Set x = 3, y = 5, z = 0.0001]
X[<X-COORD>=3]Y[<Y-COORD>=5]Z[<Z-COORD>=0.0001]<EOB>
[# Calc (x + 3)*2]
[(<X-COORD>+3)*2]<EOB>
[# Calc sqrt(pow(x, 2) + pow(y, 2))]
[sqrt(pow(<X-COORD>,2)+pow(<Y-COORD>,2))]<EOB>
[# Calc atan2d(y, x)]
[atan2d(<Y-COORD>,<X-COORD>)]<EOB>
[# Is z = 0 within +-0.001? If so, print Yes]
<IF>[apxeq(<Z-COORD>,0,0.001)]<THEN>
Yes<EOB>
<ENDIF>
[# Print special charcters]
<91><93><EOB>
[# Format x using tool's format]
[<TOOL>:<X-COORD>]<EOB>
[# Format -x as LTDUP|2.2|2]
[LTDUP|2.2|2:-<X-COORD>]<EOB>
[# Set x = 1 without printing anything]
[:<X-COORD>=1]<EOB>
[# Is x != 0 and y != 0?]
<IF>[and(not(apxeq(<X-COORD>,0)),not(apxeq(<Y-COORD>,0)))]<THEN>
Yes<EOB>
<ENDIF>
[# Set variable a = x]
[a=<X-COORD>]<EOB>
[# Calc a + 5]
[a+5]<EOB>
Expressions are surrounded by square brackets [ ]. They are evaluated prior to being output. This example multiplies the current X coordinate by five: [<X-COORD>*5]. This example offsets a rapid move by (5,5): N<SEQ>G00 X[<X-COORD>+5] Y[<Y-COORD>+5] Z<Z-COORD>.