Arithmetic and Logical Expressions

Any arithmetic expressions can be used in numerical inputs. Further processing of these expressions can also be linked to logical IF-THEN-ELSE conditions:

Only round brackets can be used as brackets, square or curly brackets are not permissible. You can use several nested brackets, but the brackets must be matched, i.e. every opening bracket must also have a closing bracket.


Arithmetic operators

The following operators can be used in an expression:

+

Addition

/

Division

-

Subtraction

^

Exponential Operator

*

Multiplication

 

 

Instead of the operator ^, the function name XHY (x to the power of y) can also be used.

An arithmetic expression is evaluated according to the usual mathematical rules.


Logical comparison expressions

A logical comparison expression refers to a simple arithmetic comparison a1 op a2, where a1 and a2 are arithmetic expressions linked to a comparison operator op; op can be one of the following operators:

=

equal to

<

less than

<>

unequal to

<

less than or equal to

>

greater than

>

greater than or equal to

A logical comparison expression, however, can be formed from several simple arithmetic comparisons using the logical operators  AND and OR.

Logical comparison expressions are important, for example, if the value assignment to a variable is to be made dependent on certain conditions.


 Basic mathematical functions

ABS

Absolute value

LOG

Natural logarithm

ACOS

Arc cosine

LOG 10

Decade logarithm

AINT

Integer (whole number portion)

NINT

Next integer value (rounds to next whole number)

ARC

Conversion of degrees to radians

SIG

Signum (sign function: 1, 0 or -1 )

ASC

ASCII code of a character

SIN

Sine

ASIN

Arc sine

SINH

Hyperbolic sine

ATAN

Arc tangent

SQR

Square

COS

Cosine

SQRT

Square root

COSH

Hyperbolic cosine

TAN

Tangent

EXP

Exponential function

TANH

Hyperbolic tangent

GRD

Conversion of radians to degrees

VAL

Convert string into number

LEN

Length of a string

 

 

Example: SQRT (A*A + B*B)  returns 

Although the trigonometric functions generally only process values in radians, inputs and results are processed and output in degrees within the HiCAD formula interpreter, depending on the angle unit defined. You use the ARC and GRD functions to convert between degrees and radians.


IF-conditions

The value assignment to a variable can depend on a condition. Two syntactic forms are possible:

where vglad stands for a logical comparison expression and a and b for any arithmetic expressions.

In the first form of the IF-condition, the value assignment is only performed if vglad is fulfilled, i.e. is true. In this case, the value of the expression a is assigned to the variable. In the other case, no value is assigned.

In the second form of the IF-condition, the value of the arithmetic expression is assigned to variable v if vglad is fulfilled; if not, the value of expression b is assigned.

The conditional value assignment will be used most within macro procedures and variants and can have extremely different forms. If, for example, you want the height of the text annotation to be selected depending on scale, a comparison of system variable @2 with a constant value generally suffices:

IF @2 < 100 THEN 2.5 ELSE 3

For scale numbers up to and including 100, annotation size 2.5 mm is selected and 3 mm for larger scales


Point, distance and angle entries

Arithmetic expressions can also be contained as a component in compound statements. For example, it is possible to use arithmetic expressions for point options A, R, P, W and D, which expect numerical arguments.

The following should be borne in mind for this application type as an argument of point options and as an argument after a distance and angle input:

Example:

P L d is interpreted as a point option "polar coordinates with the angle last used and distance d", while the expressions P (L) d or P + L d use the value of variable L as the angle.

The same applies to options Z and FA which enable you to take distances and angles from the drawing.


Formulae

For all 3-D functions for which HiCAD requests the input of a numerical value, you can also enter a formula instead of a simple value. Formulae can be entered directly during the designing process, or subsequently in the feature list. The input of a value is therefore not always required, e.g. for the length of an edge (edge_length(e1)), or the distance between 2 point (distance_points(p1,p2)). For these formulae the variables (e1,p1,p2) must have been defined in the variables list of the part. One advantage of the working with formulae is that you do not need to know the exact value, and that the parameter will adjust itself to the defined variables.

Further information can be found in the Feature Technology Help and in the Automatisation with HiCAD Whitepaper in the ISD Wiki.

© Copyright 1994-2018, ISD Software und Systeme GmbH
Version 2302 - HiCAD Basics
Date: 30/10/2018

> Feedback on this topic