set up cylinder route

This commit is contained in:
bakedpotatolord 2025-06-30 20:46:58 -06:00
commit e5d9712181
4 changed files with 116 additions and 1 deletions

View file

@ -1355,6 +1355,29 @@ CAM.init = function(kiri, api) {
});
};
func.selectHelical = () => {
console.log("select helical")
CAM.cylinderFaces((progress,msg)=>{
api.show.progress(progress,msg)
},(data)=>{
console.log(data)
func.selectHelicalDone(data);
})
}
func.selectHelicalDone = () =>{
console.log("select helical done")
}
// COMMON TAB/TRACE EVENT HANDLERS
api.event.on("slice.begin", () => {
if (isCamMode) {
@ -1864,7 +1887,7 @@ CAM.init = function(kiri, api) {
sep: UC.newBlank({class:"pop-sep"}),
thru: UC.newInput(LANG.cd_thru_s, {title:LANG.cd_thru_l, convert:UC.toFloat, units:true}),
actions: UC.newRow([
UC.newButton(LANG.select, ()=>func.selectHoles(true), {title:LANG.cd_seli_l}),
UC.newButton(LANG.select, func.selectHelical, {title:LANG.cd_seli_l}),
], {class:"ext-buttons f-col"})
};

View file

@ -99,6 +99,29 @@ kiri.load(api => {
});
})
};
CAM.cylinderFaces = function(opProgress,onDone){
kiri.client.sync();
const settings = api.conf.get();
return new Promise((res,rej)=>{
console.log("messaging worker")
kiri.client.send("cam_cylinder_faces", { settings }, output => {
let out = kiri.codec.decode(output)
if(out.progress != undefined){
//if a progress message,
opProgress(out.progress,out.msg)
}else{
api.hide.alert(alert);
onDone(out);
res(out);
}
});
})
}
}
if (kiri.worker) {
@ -181,6 +204,25 @@ kiri.load(api => {
shadowed:widget.shadowedDrills
} } )));
}
kiri.worker.cam_cylinder_faces = async function(data,send){
const { settings, rec } = data;
const widgets = Object.values(kiri.worker.cache);
console.log("hi from the worker")
for (let [i,widget] of widgets.entries() ) {
if (await CAM.cylinders(settings, widget,)) {
let {traces} = widget;
console.log("traces",traces)
traces.filter(t=>t)
}
}
}
}
});

View file

@ -1726,6 +1726,49 @@ class OpRegister extends CamOp {
}
}
class OpHelical extends CamOp {
constructor(state, op) {
super(state, op);
}
async slice(progress){
let { op, state } = this;
let { settings, addSlices, widget, updateToolDiams } = state;
let { zBottom, zThru, thruHoles, color } = state;
let { drills, drillThrough} = op
let drillTool = new CAM.Tool(settings, op.tool),
drillToolDiam = drillTool.fluteDiameter(),
sliceOut = this.sliceOut = [];
updateToolDiams(drillToolDiam);
let slice = newSlice(0);
let poly = newPolygon();
slice.camTrace = { tool: op.tool, rate: op.feed, plunge: op.rate };
slice.camLines = [poly];
slice.output()
.setLayer("Helical", {face: color, line: color})
.addPolys(slice.camLines);
addSlices(slice);
sliceOut.push(slice);
}
async prepare(ops, progress){
}
}
class OpXRay extends CamOp {
constructor(state, op) {
super(state, op);
@ -1958,6 +2001,7 @@ CAM.OPS = CamOp.MAP = {
"trace": OpTrace,
"drill": OpDrill,
"register": OpRegister,
"helical": OpHelical,
"laser on": OpLaserOn,
"laser off": OpLaserOff,
"gcode": OpGCode,

View file

@ -515,6 +515,12 @@ CAM.traces = async function(settings, widget, single) {
return true;
};
CAM.cylinders = async (settings, widget) => {
//this is where the migic is gonna happen
}
/**
* Generate a list of holes in the model based on the given diameter.
*