Formulas in Macros

CIMCO Edit can calculate and output values based upon a user input value. This has many uses and increases the power of the macro function.

CIMCO Edit includes a sample 'Formulas.MAC' file type that includes useful examples of formulas in macros. Start CIMCO Edit V8 and select Formulas in the File Type drop-down list.

Sample formulas.

The formulas are used much the same as variables, and are called @N as opposed to $N, and allow the same formatting. To add a formula, enter the Macro Setup and press the Add Formula button. Build your formula inside the {}.


The formulas support * / + - % (for modulus), nested expressions using () and the following elementary functions: abs, acos, asin, atan, cos, cosh, floor, ln, log, sign, sin, sinh, sqrt, tan and tanh.

PI can be used instead of entering 3.1416.

Angles are in degrees.

Please use () for the input values in the trigonometric functions, e.g. sin($1)

If you only need to output the calculated value into the NC program include all your user input values inside the formula expression. When the Circle Area macro below is run only the @2 variable is output into the NC program.

Adding a formula to a macro.

Inserting a macro with formulas.

Hiding the Formula Results

You can choose to hide the results of the calculations on the insert macro dialog.

This can be done by using the global setting Hide NC-Assistant formula results in the General settings dialog. All your macros will not show the results on the macro dialog.

Global setting to hide the formula results.

The output is the same in the NC file but the dialog does not show the calculated values. This can be useful if you have many calculated values in the macro.

Macro with the results being shown.

Same macro without the results being shown.

There is an option in the Macro Setup dialog to display the formula results for each macro individually. If the Hide NC-Assistant formula results is selected in General settings it will override the Macro Setup option.

Macro specific setting to hide the formula results.

Formatting of Formula Values

The formatting of formula values is the same as for normal user input values.

Formula values format.

You can also select As specified for the number of decimals for formula values. If you enter 10 (no decimal point) as the user input the formula value will be formatted with no decimal point when it is output in the NC file. If you enter 10. (with decimal point) the formula value is output with the decimal point.

Please check the results of the formulas carefully to make sure you are getting the correct value and format.

Outputting Fanuc Macro B Variables

The macros can output any text. If you need to output a Fanuc Macro B variable e.g. #1 you may need to include an extra # in front of the variable. The # symbol is used by the macros to output a line number and by putting an extra # it stops the line number being output.

Please see the Macro B Circle macro in the supplied 'Formulas.MAC' file.

Fanuc Macro B sample macro.