Merge branch 'drill-type' of github.com:bakedPotatoLord/grid-apps into bakedPotatoLord-drill-type
This commit is contained in:
commit
3aa56706c1
5 changed files with 71 additions and 12 deletions
|
|
@ -3,6 +3,8 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
// dep: kiri-mode.cam.driver
|
// dep: kiri-mode.cam.driver
|
||||||
|
// dep: kiri.api
|
||||||
|
// dep: kiri.alerts
|
||||||
// use: kiri-mode.cam.animate
|
// use: kiri-mode.cam.animate
|
||||||
// use: kiri-mode.cam.animate2
|
// use: kiri-mode.cam.animate2
|
||||||
// use: kiri-mode.cam.tools
|
// use: kiri-mode.cam.tools
|
||||||
|
|
@ -10,7 +12,8 @@
|
||||||
gapp.register("kiri-mode.cam.client", [], (root, exports) => {
|
gapp.register("kiri-mode.cam.client", [], (root, exports) => {
|
||||||
|
|
||||||
const { base, kiri } = root;
|
const { base, kiri } = root;
|
||||||
const { driver } = kiri;
|
const { driver, api } = kiri;
|
||||||
|
const {alerts, conf} = api;
|
||||||
const { CAM } = driver;
|
const { CAM } = driver;
|
||||||
const DEG2RAD = Math.PI / 180;
|
const DEG2RAD = Math.PI / 180;
|
||||||
const RAD2DEG = 180 / Math.PI;
|
const RAD2DEG = 180 / Math.PI;
|
||||||
|
|
@ -1728,6 +1731,17 @@ function createPopOp(type, map) {
|
||||||
},
|
},
|
||||||
bind: (ev) => {
|
bind: (ev) => {
|
||||||
API.util.ui2rec(op.rec, op.inputs);
|
API.util.ui2rec(op.rec, op.inputs);
|
||||||
|
|
||||||
|
const settings = conf.get();
|
||||||
|
const {tool} = new CAM.Tool(settings,op.rec.tool); //get tool by id
|
||||||
|
const opType = op.rec.type
|
||||||
|
if( opType != "drill" && tool.type == "drill"){
|
||||||
|
alerts.show(`Warning: Drills should not be used for ${opType} operations.`)
|
||||||
|
}
|
||||||
|
if( opType == "drill" && tool.type != "drill"){
|
||||||
|
alerts.show(`Warning: Only drills should be used for drilling operations.`)
|
||||||
|
}
|
||||||
|
|
||||||
for (let [key, val] of Object.entries(op.rec)) {
|
for (let [key, val] of Object.entries(op.rec)) {
|
||||||
let saveTo = map[key];
|
let saveTo = map[key];
|
||||||
if (saveTo && typeof(key) === 'string' && !key.startsWith("~")) {
|
if (saveTo && typeof(key) === 'string' && !key.startsWith("~")) {
|
||||||
|
|
|
||||||
|
|
@ -67,11 +67,11 @@ class Tool {
|
||||||
}
|
}
|
||||||
|
|
||||||
traceOffset() {
|
traceOffset() {
|
||||||
return (this.isTaperMill() ? this.tipDiameter() : this.fluteDiameter()) / 2;
|
return (this.hasTaper() ? this.tipDiameter() : this.fluteDiameter()) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
contourOffset(step) {
|
contourOffset(step) {
|
||||||
const diam = Math.min(this.isTaperMill() ? this.tipDiameter() : this.fluteDiameter());
|
const diam = Math.min(this.hasTaper() ? this.tipDiameter() : this.fluteDiameter());
|
||||||
return diam ? diam * step : step;
|
return diam ? diam * step : step;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -100,10 +100,18 @@ class Tool {
|
||||||
return this.tool.type === "tapermill";
|
return this.tool.type === "tapermill";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isDrill(){
|
||||||
|
return this.tool.type === "drill";
|
||||||
|
}
|
||||||
|
|
||||||
|
hasTaper() {
|
||||||
|
return this.isTaperMill();
|
||||||
|
}
|
||||||
|
|
||||||
generateProfile(resolution) {
|
generateProfile(resolution) {
|
||||||
// generate tool profile
|
// generate tool profile
|
||||||
let ball = this.isBallMill(),
|
let ball = this.isBallMill(),
|
||||||
taper = this.isTaperMill(),
|
taper = this.hasTaper(),
|
||||||
tip_diameter = this.tipDiameter(),
|
tip_diameter = this.tipDiameter(),
|
||||||
shaft_offset = this.fluteLength(),
|
shaft_offset = this.fluteLength(),
|
||||||
flute_diameter = this.fluteDiameter(),
|
flute_diameter = this.fluteDiameter(),
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,8 @@ gapp.register("kiri-mode.cam.tools", (root, exports) => {
|
||||||
DOC = document,
|
DOC = document,
|
||||||
selectedTool = null,
|
selectedTool = null,
|
||||||
editTools = null,
|
editTools = null,
|
||||||
maxTool = 0;
|
maxTool = 0,
|
||||||
|
toolNames = ['endmill','ballmill','tapermill','drill'];
|
||||||
|
|
||||||
api.show.tools = showTools;
|
api.show.tools = showTools;
|
||||||
|
|
||||||
|
|
@ -41,6 +42,8 @@ gapp.register("kiri-mode.cam.tools", (root, exports) => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function selectTool(tool) {
|
function selectTool(tool) {
|
||||||
selectedTool = tool;
|
selectedTool = tool;
|
||||||
ui.toolName.value = tool.name;
|
ui.toolName.value = tool.name;
|
||||||
|
|
@ -51,11 +54,14 @@ gapp.register("kiri-mode.cam.tools", (root, exports) => {
|
||||||
ui.toolShaftLen.value = tool.shaft_len;
|
ui.toolShaftLen.value = tool.shaft_len;
|
||||||
ui.toolTaperTip.value = tool.taper_tip || 0;
|
ui.toolTaperTip.value = tool.taper_tip || 0;
|
||||||
ui.toolMetric.checked = tool.metric;
|
ui.toolMetric.checked = tool.metric;
|
||||||
ui.toolType.selectedIndex = ['endmill','ballmill','tapermill'].indexOf(tool.type);
|
ui.toolType.selectedIndex = toolNames.indexOf(tool.type);
|
||||||
if (tool.type === 'tapermill') {
|
if (tool === 'tapermill') {
|
||||||
ui.toolTaperAngle.value = kiri.driver.CAM.calcTaperAngle(
|
ui.toolTaperAngle.value = kiri.driver.CAM.calcTaperAngle(
|
||||||
(tool.flute_diam - tool.taper_tip) / 2, tool.flute_len
|
(tool.flute_diam - tool.taper_tip) / 2, tool.flute_len
|
||||||
).round(1);
|
).round(1);
|
||||||
|
} else if(tool === 'drill'){
|
||||||
|
ui.toolTaperAngle.value = 118;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
ui.toolTaperAngle.value = 0;
|
ui.toolTaperAngle.value = 0;
|
||||||
}
|
}
|
||||||
|
|
@ -83,7 +89,9 @@ gapp.register("kiri-mode.cam.tools", (root, exports) => {
|
||||||
|
|
||||||
function renderTool(tool) {
|
function renderTool(tool) {
|
||||||
let type = selectedTool.type;
|
let type = selectedTool.type;
|
||||||
let taper = type === 'tapermill';
|
let taper = type=== 'tapermill'
|
||||||
|
let drill = type === 'drill'
|
||||||
|
const drillAngleRad = 140 * Math.PI / 180
|
||||||
ui.toolTaperAngle.disabled = taper ? undefined : 'true';
|
ui.toolTaperAngle.disabled = taper ? undefined : 'true';
|
||||||
ui.toolTaperTip.disabled = taper ? undefined : 'true';
|
ui.toolTaperTip.disabled = taper ? undefined : 'true';
|
||||||
$('tool-view').innerHTML = '<svg id="tool-svg" width="100%" height="100%"></svg>';
|
$('tool-view').innerHTML = '<svg id="tool-svg" width="100%" height="100%"></svg>';
|
||||||
|
|
@ -101,10 +109,12 @@ gapp.register("kiri-mode.cam.tools", (root, exports) => {
|
||||||
stroke_thin = stroke_width / 2,
|
stroke_thin = stroke_width / 2,
|
||||||
shaft = tool.shaft_len || 1,
|
shaft = tool.shaft_len || 1,
|
||||||
flute = tool.flute_len || 1,
|
flute = tool.flute_len || 1,
|
||||||
total_len = shaft + flute,
|
drillTip = drill ? 0.5 * tool.flute_diam * Math.sin(drillAngleRad) : 0,
|
||||||
|
total_len = shaft + flute+drillTip,
|
||||||
units = dim.h / total_len,
|
units = dim.h / total_len,
|
||||||
shaft_len = (shaft / total_len) * max.h,
|
shaft_len = (shaft / total_len) * max.h,
|
||||||
flute_len = ((flute / total_len) * max.h),
|
flute_len = (flute / total_len) * max.h,
|
||||||
|
drill_tip_len = (drillTip / total_len) * max.h,
|
||||||
shaft_diam = tool.shaft_diam * units,
|
shaft_diam = tool.shaft_diam * units,
|
||||||
flute_diam = tool.flute_diam * units,
|
flute_diam = tool.flute_diam * units,
|
||||||
// total_wid = Math.max(flute_diam, shaft_diam),
|
// total_wid = Math.max(flute_diam, shaft_diam),
|
||||||
|
|
@ -123,7 +133,7 @@ gapp.register("kiri-mode.cam.tools", (root, exports) => {
|
||||||
stroke
|
stroke
|
||||||
} }
|
} }
|
||||||
];
|
];
|
||||||
if (type === "tapermill") {
|
if (taper) {
|
||||||
let yoff = off.y + shaft_len;
|
let yoff = off.y + shaft_len;
|
||||||
// let mid = dim.w / 2;
|
// let mid = dim.w / 2;
|
||||||
parts.push({path: {stroke_width, stroke, fill:flute_fill, d:[
|
parts.push({path: {stroke_width, stroke, fill:flute_fill, d:[
|
||||||
|
|
@ -133,6 +143,31 @@ gapp.register("kiri-mode.cam.tools", (root, exports) => {
|
||||||
`L ${dim.w - off.x - flute_off} ${yoff}`,
|
`L ${dim.w - off.x - flute_off} ${yoff}`,
|
||||||
`z`
|
`z`
|
||||||
].join('\n')}});
|
].join('\n')}});
|
||||||
|
} else if(drill){
|
||||||
|
|
||||||
|
const x1 = off.x + flute_off,
|
||||||
|
y1 = off.y + shaft_len,
|
||||||
|
x2 = dim.w - off.x - flute_off,
|
||||||
|
y2 = y1 + flute_len,
|
||||||
|
xMid = dim.w / 2
|
||||||
|
|
||||||
|
parts.push({path: {stroke_width, stroke, fill:flute_fill, d:[
|
||||||
|
`M ${x1} ${y1}`, //move to top left
|
||||||
|
`L ${x1} ${y2}`, //line to bottom left
|
||||||
|
`L ${xMid} ${y2+drill_tip_len}`, //line to bottom mid point
|
||||||
|
`L ${x2} ${y2}`, //line to bottom right
|
||||||
|
`L ${x2} ${y1}`, //line to top right
|
||||||
|
`z`
|
||||||
|
].join('\n')}});
|
||||||
|
//add drill flute lines
|
||||||
|
parts.push({ line: {
|
||||||
|
x1, y1, x2, y2: (y1 + y2) / 2,
|
||||||
|
stroke, stroke_width: stroke_thin
|
||||||
|
} });
|
||||||
|
parts.push({ line: {
|
||||||
|
x1, y1: (y1 + y2) / 2, x2, y2,
|
||||||
|
stroke, stroke_width: stroke_thin
|
||||||
|
} });
|
||||||
} else {
|
} else {
|
||||||
let fl = isBall ? flute_len - flute_diam/2 : flute_len;
|
let fl = isBall ? flute_len - flute_diam/2 : flute_len;
|
||||||
let x1 = off.x + flute_off;
|
let x1 = off.x + flute_off;
|
||||||
|
|
@ -183,7 +218,7 @@ gapp.register("kiri-mode.cam.tools", (root, exports) => {
|
||||||
selectedTool.shaft_len = parseFloat(ui.toolShaftLen.value);
|
selectedTool.shaft_len = parseFloat(ui.toolShaftLen.value);
|
||||||
selectedTool.taper_tip = parseFloat(ui.toolTaperTip.value);
|
selectedTool.taper_tip = parseFloat(ui.toolTaperTip.value);
|
||||||
selectedTool.metric = ui.toolMetric.checked;
|
selectedTool.metric = ui.toolMetric.checked;
|
||||||
selectedTool.type = ['endmill','ballmill','tapermill'][ui.toolType.selectedIndex];
|
selectedTool.type = toolNames[ui.toolType.selectedIndex];
|
||||||
if (selectedTool.type === 'tapermill') {
|
if (selectedTool.type === 'tapermill') {
|
||||||
const CAM = kiri.driver.CAM;
|
const CAM = kiri.driver.CAM;
|
||||||
const rad = (selectedTool.flute_diam - selectedTool.taper_tip) / 2;
|
const rad = (selectedTool.flute_diam - selectedTool.taper_tip) / 2;
|
||||||
|
|
|
||||||
|
|
@ -557,6 +557,7 @@
|
||||||
<option value="endmill" lk="td_tyem" selected>end</option>
|
<option value="endmill" lk="td_tyem" selected>end</option>
|
||||||
<option value="ballmill" lk="td_tybm">ball</option>
|
<option value="ballmill" lk="td_tybm">ball</option>
|
||||||
<option value="tapermill" lk="td_tytm">taper</option>
|
<option value="tapermill" lk="td_tytm">taper</option>
|
||||||
|
<option value="drill" lk="td_tydr">drill</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="f-row var-row" title="tool number to use
in gcode commands"><label lk="td_tonm">tool #</label><input id="tool-num" size="7"></input></div>
|
<div class="f-row var-row" title="tool number to use
in gcode commands"><label lk="td_tonm">tool #</label><input id="tool-num" size="7"></input></div>
|
||||||
|
|
|
||||||
|
|
@ -92,6 +92,7 @@ self.kiri.lang['en-us'] = {
|
||||||
td_tyem: "end", // end mill
|
td_tyem: "end", // end mill
|
||||||
td_tybm: "ball", // ball mill
|
td_tybm: "ball", // ball mill
|
||||||
td_tytm: "taper", // taper mill
|
td_tytm: "taper", // taper mill
|
||||||
|
td_tydr: "drill", // drill
|
||||||
td_tonm: "tool #",
|
td_tonm: "tool #",
|
||||||
td_shft: "shaft", // endmill shaft specs
|
td_shft: "shaft", // endmill shaft specs
|
||||||
td_flut: "flute", // endmill flute specs
|
td_flut: "flute", // endmill flute specs
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue