@volkcnc none of the code above actually writes anything out.. it's just pulling values from the post output, storing them as variables, and in the case of mainSpindlePartExtension variable.. performs some math.
Put this in onOpen() and it will work for you:
// Write Stock
writeComment("Stock Diameter = " + xFormat.format(toPreciseUnit(getGlobalParameter("stock-upper-x"), MM)) + (unit == MM ? "mm" : "\""));
var orginRef;
switch (getGlobalParameter("chuck-front-mode")) {
case "stock front":
orginRef = toPreciseUnit(getGlobalParameter("stock-upper-z"), MM);
break;
case "stock back":
orginRef = toPreciseUnit(getGlobalParameter("stock-lower-z"), MM);
break;
case "model front":
orginRef = toPreciseUnit(getGlobalParameter("part-upper-z"), MM);
break;
case "model back":
orginRef = toPreciseUnit(getGlobalParameter("part-lower-z"), MM);
break;
default:
error(localize("Chuck reference must be set to Model or Stock, back or front"));
}
var mainSpindlePartExtension = Math.abs(toPreciseUnit(getGlobalParameter("chuck-front-offset"), MM) + orginRef);
writeComment("Stock Stickout = " + zFormat.format(mainSpindlePartExtension) + (unit == MM ? "mm" : "\""));

Scott Moyse
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

RevOps Strategy Manager at Toolpath. New Zealand based.
Co-founder of the Grumpy Sloth full aluminium billet mechanical keyboard project