From 3ce1950882af0bf108c01f3b78bccd3ea14cd121 Mon Sep 17 00:00:00 2001 From: "Williams, Gavin J" Date: Tue, 14 Sep 2021 13:42:18 -0400 Subject: [PATCH] Added Tool Selection --- Haas_Gantry_BIDC/Bechtel SR.cps | 60 +++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 2 deletions(-) diff --git a/Haas_Gantry_BIDC/Bechtel SR.cps b/Haas_Gantry_BIDC/Bechtel SR.cps index 38d9c2b..e0ef7a6 100644 --- a/Haas_Gantry_BIDC/Bechtel SR.cps +++ b/Haas_Gantry_BIDC/Bechtel SR.cps @@ -171,7 +171,7 @@ properties = {/* {title: "Cycles", id: "cycles"}, {title: "Patterns", id: "patterns"} ], - value: "allOperations", + value: "none", scope: "post" },/* useG187: { @@ -260,6 +260,14 @@ properties = {/* value: true, scope: "post" }*/ + toolsToLoad: { + title: "Tools to load and probe", + description: "List or provide a range of tools to probe e.g. 1, 2, 3 or 1-5. Leaving this empty will probe all tools", + group: 4, + type: "string", + value: "", + scope: "post" + }, pencilWCSValidation: { title: "WCS Validation", description: "WCS validation. By turning this off, you accept responsibility for any resulting crashes.", @@ -281,7 +289,7 @@ properties = {/* description: "Tool Probing. By turning this off, you accept responsibility for any resulting crashes.", group: 99, type: "boolean", - value: false, + value: true, scope: "post" } }; @@ -905,11 +913,59 @@ function onOpen() { writeComment(localize("Once the tools are verified turn BLOCK DELETE on to skip verification")); */ + parsedTools = [] + + function defaultFill() { + for (var i = 0; i < tools.getNumberOfTools(); i++){ + parsedTools[i] = tools.getTool(i).number; + } + } + + function invalidToolNum(toolNum) { + return (toolNum < 1 || toolNum > 10); + } + // parse string for specific tools to load + if (getProperty("toolsToLoad") != "") { + // get list of numbers + let toolNumArray = getProperty("toolsToLoad").split(','); + // iterate through and fill ranges + for (var i = 0; i < toolNumArray.length; i++){ + toolNumArray[i] = toolNumArray[i].trim(); + + // fill range + if (toolNumArray[i].indexOf("-") >= 0) { + let numRange = toolNumArray[i].split("-"); + if (invalidToolNum(parseInt(numRange[0])) || invalidToolNum(parseInt(numRange[1]))) { + defaultFill(); + break; + } + for(var j = numRange[0]; j <= numRange[1]; j++){ + parsedTools.push(parseInt(j)); + } + continue; + } + // check if valid num + if (invalidToolNum(parseInt(toolNumArray[i]))) { + defaultFill(); + break; + } + // push single num + parsedTools.push(parseInt(toolNumArray[i])); + } + } else { + defaultFill(); + } + for (var i = 0; i < tools.getNumberOfTools(); ++i) { var tool = tools.getTool(i); if (staticProperties.optionallyMeasureToolsAtStart && (tool.type == TOOL_PROBE)) { continue; } + + if (parsedTools.indexOf(tool.number) <= -1) { + continue; + } + var comment = "T" + toolFormat.format(tool.number) + " " + "D=" + xyzFormat.format(tool.diameter) + " " + localize("CR") + "=" + xyzFormat.format(tool.cornerRadius);