ShopDocs · Glossary Definition

Custom Macro

Quick Technical FAQs
Is Custom Macro the same as a subprogram?

No. A subprogram repeats fixed code, while Custom Macro adds variables, arithmetic, and logic so the same code can change behavior based on inputs.

What makes it parametric?

The machining geometry is driven by parameters passed into the macro, such as X, Y, W, H, D, or other numeric arguments, rather than hard-coded values.

Can macros create user-defined canned cycles?

Yes. Custom Macro can emulate canned cycles and, with modal calling methods, repeat a user-created cycle until canceled.

Primary Definition & Context

Custom Macro, primarily FANUC Custom Macro B, is a parametric programming extension to G-code that allows variables, arithmetic, logic, branching, loops, and custom alarms. Instead of hard-coded coordinates, a single macro can machine a family of parts by accepting different dimensions as arguments, drastically reducing programming time and errors.

On the shop floor, Custom Macro proves invaluable for part-family machining. A programmer writes one master program for a bolt circle, pocketing, or engraving pattern, and then calls it with varying parameters—hole count, diameter, depth—from the main program. The macro reads these arguments, calculates tool positions, and executes the cut. This eliminates repetitive programming and reduces setup errors. Additionally, macros serve as the logic layer for automation: they interface with touch probes for in-process measurement, trigger alarms if tolerances are exceeded, and adjust offsets based on probe results. In production cells, modal macro calls (G66.1) run repeatedly until canceled (G67), enabling unattended operation. The same concept applies to millwork and cabinet manufacturing where dimensions change per job, standardizing operations like repetitive drilling and pocketing while minimizing edit time. By embedding decision logic, macros also prevent crashes by checking inputs against safe limits before executing moves.

Critical Pitfalls

Variable overwrite or bad argument mapping: If local or common variables are reused incorrectly, the macro calculates wrong geometry, leading to shifted holes or wrong pocket sizes. The code appears correct but the part is scrap.

No safe limits or guard logic: Without checks for minimum stock or maximum depth, an out-of-range input can cause the machine to hit clamps, cut air, or break tools.

Poor control-specific implementation: Macro syntax and functions vary between controls, so copying code without validation can cause logic faults, unsupported calls, or incorrect cycle behavior.

Software that works like your best tools.

This Glossary is maintained by Ryxen — focused software tools that solve specific operational friction points for Canadian small businesses. No ERP bloat, no per-user pricing, no demo calls.