All you need is to call your function in a apropriate case in 'onCycle()' switch statement
case "gun-drilling":
onCustomGunDrilling(cycle);
break;
this is my implementation:
function onCustomGunDrilling(cycle) {
writeBlock(";CYCL DEF 241 " + localize("SINGLE-FLUTED DEEP-HOLE DRILLING"));
writeBlock(" Q200=" + xyzFormat.format(cycle.retract - cycle.stock) + " ;" + localize("SET-UP CLEARANCE"));
writeBlock(" Q201=" + xyzFormat.format(-cycle.depth) + " ;" + localize("DEPTH"));
writeBlock(" Q206=" + feedFormat.format(cycle.feedrate) + " ;" + localize("FEED RATE FOR PLUNGING"));
writeBlock(" Q211=" + secFormat.format(cycle.dwell) + " ;" + localize("DWELL TIME AT DEPTH"));
writeBlock(" Q203=" + xyzFormat.format(cycle.stock) + " ;" + localize("SURFACE COORDINATE"));
writeBlock(" Q204=" + xyzFormat.format(cycle.clearance - cycle.stock) + " ;" + localize("2ND SET-UP CLEARANCE"));
writeBlock(" Q379=" + xyzFormat.format(cycle.startingDepth) + " ;" + localize("STARTING POINT"));
writeBlock(" Q253=" + feedFormat.format(cycle.positioningFeedrate) + " ;" + localize("F PRE-POSITIONING"));
writeBlock(" Q208=" + feedFormat.format(cycle.retractFeedrate) + " ;" + localize("RETRACT FEED RATE"));
writeBlock(" Q426=" + (cycle.stopSpindle ? 5 : (tool.clockwise ? 3 : 4)) + " ;" + localize("DIR. OF SPINDLE ROT."));
writeBlock(" Q427=" + rpmFormat.format(getAdjustedRPM(cycle.positioningSpindleSpeed ? cycle.positioningSpindleSpeed : tool.spindleRPM)) + " ;" + localize("ENTRY EXIT SPEED"));
writeBlock(" Q428=" + rpmFormat.format(getAdjustedRPM(tool.spindleRPM)) + " ;" + localize("DRILLING SPEED"));
writeBlock(" Q429=" + (coolantCode ? coolantCode[0] : 8) + " ;" + localize("COOLANT ON"));
writeBlock(" Q430=" + (coolantCode ? coolantCode[1] : 9) + " ;" + localize("COOLANT OFF"));
writeBlock(" Q435=" + xyzFormat.format(cycle.dwellDepth ? (cycle.depth - cycle.dwellDepth) : 0) + " ;" + localize("DWELL DEPTH"));
writeBlock(" Q401=" + xyzFormat.format(qParameter.Q401.value) + " ;VORSCHUBFAKTOR");
writeBlock(" Q202=" + xyzFormat.format(qParameter.Q202.value) + " ;MAX. ZUSTELL-TIEFE");
writeBlock(" Q212=" + xyzFormat.format(qParameter.Q212.value) + " ;ABNAHMEBETRAG");
writeBlock(" Q205=" + xyzFormat.format(qParameter.Q205.value) + " ;MIN. ZUSTELL-TIEFE");
writeBlock("CYCL DEF 12.0 PGM CALL");
writeBlock("CYCL DEF 12.1 PGM TNC:\\1_UNTERPROGRAMME\\MY241.H");
}
Note that CYCL DEF is commentet out and all following Q-Parameters are 'parameters' that are used in MY241.H
No big changes are needed in PP, the last two lines from function onCustomDrillingCycle() do the trick.