I know my way around Fanuc custom macro pretty well, but this thing has me befuddled. I'm trying to create a custom G code, and be able to input variables just like you can with normal G codes, i.e. G1 Xnn Ynn Znn. I'm led down the garden path by the manual to believe this is possible. Just write a sequence of commands and stick it in the 4M_SUB.DAT file and away you go. I did this and the command doesn't do anything. No matter what I call the command, G121, G66.1, whatever, I get a "E402: The user G code is not defined" error. I dug around in the 4M directory and found a file called 4M_CODE.H which seems to contain definitions for most of the macros in the 4M_SUB.DAT file, so I dutifully created my definition for the custom G code, and ... nada. Ignores it just like before. I also tried M codes, and this doesn't generate any errors, but it also doesn't execute the macro. I've tried every conceivable variation in syntax, even copying another canned cycle verbatim like G84 and renaming it, no dice. Re the 4m_code.h file, in the software world, a ".h" file is usually implies a source file, in C/C++ it's a header file, I think. That would be tragic if it would require some unobtainable compiler to "bake" the custom code to the .exe. Without this capability, my automatic, customizable probing cycles can't work, because there would be no way to input a definition of what to probe, i.e bore, boss, size of feature, etc. I guess I could run it as a program and manually stuff everything in macro variables, but as someone put it so elegantly in another forum years ago "I'd rather pull nose hairs with pliers".

Just opened the 4m.exe with a hex viewer, and I definitely see references to G codes in there. It's, of course, unintelligible gibberish, just like any executable, so a bit hard to draw any conclusions... Someone with knowledge in this arcane art could probably do a stack trace and figure out what happens when you launch a G84, but that would not be me.

Has anyone out there managed to create a custom G code for a 4M control?