Skip to content

Commit

Permalink
Added Tool Selection
Browse files Browse the repository at this point in the history
  • Loading branch information
will1742 committed Sep 14, 2021
1 parent ca32b19 commit 3ce1950
Showing 1 changed file with 58 additions and 2 deletions.
60 changes: 58 additions & 2 deletions Haas_Gantry_BIDC/Bechtel SR.cps
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ properties = {/*
{title: "Cycles", id: "cycles"},
{title: "Patterns", id: "patterns"}
],
value: "allOperations",
value: "none",
scope: "post"
},/*
useG187: {
Expand Down Expand Up @@ -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.",
Expand All @@ -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"
}
};
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 3ce1950

Please sign in to comment.