From 73e4a41e9babe848a959c0d9a944c6f5466361a9 Mon Sep 17 00:00:00 2001 From: pan261 Date: Thu, 2 Sep 2021 15:32:21 -0400 Subject: [PATCH] Fixed null bug with optional tool measuring --- Haas_Mills_BIDC/Bechtel VF2.cps | 36 ++++++++++++++++----------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/Haas_Mills_BIDC/Bechtel VF2.cps b/Haas_Mills_BIDC/Bechtel VF2.cps index 265c9e8..aea1f0f 100644 --- a/Haas_Mills_BIDC/Bechtel VF2.cps +++ b/Haas_Mills_BIDC/Bechtel VF2.cps @@ -894,8 +894,7 @@ function prepareForToolCheck() { } function writeToolMeasureBlock(tool, preMeasure) { - var writeBlockFunction = getProperty("measureToolsAtStart") ? writeBlock : writeOptionalBlock; - var writeWordsFunction = getProperty("measureToolsAtStart") ? writeWords() : writeWordsOptional; + var writeFunction = getProperty("measureToolsAtStart") ? writeBlock : writeOptionalBlock; var comment = measureTool ? formatComment("MEASURE TOOL") : ""; if (!preMeasure) { @@ -903,7 +902,7 @@ function writeToolMeasureBlock(tool, preMeasure) { } if (!staticProperties.useP9995) { // use Macro P9023 to measure tools var probingType = getHaasProbingTypeBIDC(tool.type, true); - writeBlockFunction( + writeFunction( gFormat.format(65), "P9023", "A" + probingType + ".", @@ -917,7 +916,7 @@ function writeToolMeasureBlock(tool, preMeasure) { setMacro(1600 + tool.number, tool.numberOfFlutes, "Number of Flutes", !getProperty("measureToolsAtStart")); setMacro(2400 + tool.number, xyzFormat.format(tool.diameter), "Tool Diameter", !getProperty("measureToolsAtStart")); var probeType = getHaasProbingTypeBIDC(tool, false); - writeBlockFunction( + writeFunction( gFormat.format(65), "P9995", "A0.", @@ -929,17 +928,20 @@ function writeToolMeasureBlock(tool, preMeasure) { "K" + xyzFormat.format(getHaasKFactorBIDC(tool)), "I0.", comment - ); // probe tool - writeWordsFunction("IF [[#" + (2000 + tool.number) + " GT " + + ); // probe tooling + var line1 = "IF [[#" + (2000 + tool.number) + " GT " + (tool.bodyLength + tool.holderLength + LENGTH_TOLERANCE).toFixed(2) + "] OR [#" + (2000 + tool.number) + " LT " + - (tool.bodyLength + tool.holderLength - LENGTH_TOLERANCE).toFixed(2) + "]] THEN #3000 = 1 (Tool length out of tolerance)"); - + (tool.bodyLength + tool.holderLength - LENGTH_TOLERANCE).toFixed(2) + "]] THEN #3000 = 1 (Tool length out of tolerance)"; + + writeWords(getProperty("measureToolsAtStart") ? line1 : "/ " + line1); if (probeType == 3) { - writeWordsFunction("IF [[#" + (2400 + tool.number) + " GT " + + var line2 = "IF [[#" + (2400 + tool.number) + " GT " + (tool.diameter + DIAM_TOLERANCE).toFixed(2) + "] OR [#" + (2400 + tool.number) + " LT " + - (tool.diameter - DIAM_TOLERANCE).toFixed(2) + "]] THEN #3000 = 1 (Tool diameter out of tolerance)"); + (tool.diameter - DIAM_TOLERANCE).toFixed(2) + "]] THEN #3000 = 1 (Tool diameter out of tolerance)"; + + writeWords(getProperty("measureToolsAtStart") ? line2 : "/ " + line2); } } measureTool = false; @@ -949,15 +951,11 @@ function writeToolMeasureBlock(tool, preMeasure) { // 002 Improved Probing // sets specified macro number with value function setMacro(macro, value, comment, isOptional) { - if (isOptional) { - writeWordsOptional("#" + macro + "=" + value, "(" + comment + ")"); - } else { - writeWords("#" + macro + "=" + value, "(" + comment + ")"); - } -} - -function writeWordsOptional(text) { - writeWords("/ " + text); + if (isOptional) { + writeWords("/ #" + macro + "=" + value, "(" + comment + ")"); + } else { + writeWords("#" + macro + "=" + value, "(" + comment + ")"); + } }