add CAM helical clockwise, reverse, and entry params

This commit is contained in:
bakedpotatolord 2025-07-19 16:17:36 -06:00
commit b467984222
5 changed files with 94 additions and 8 deletions

View file

@ -65,6 +65,10 @@
"camHelicalForceStartAngle": false,
"camHelicalStartAngle": 0,
"camHelicalOffsetOverride": 0,
"camHelicalEntry": false,
"camHelicalEntryOffset":0,
"camHelicalReverse": false,
"camHelicalClockwise": true,
"camFlipAxis": "X",
"camFlipOther": "",
"camTabsWidth": 20,

View file

@ -529,6 +529,10 @@ export const conf = {
camHelicalForceStartAngle: false,
camHelicalStartAngle: 0,
camHelicalOffsetOverride: 0,
camHelicalEntry: false,
camHelicalEntryOffset:0,
camHelicalReverse: false,
camHelicalClockwise: true,
camFlipAxis: "X",
camFlipOther: "",
camLaserEnable: ["M321"],

View file

@ -535,6 +535,10 @@ export function createPopOps() {
finish: 'camHelicalBottomFinish',
startAng:'camHelicalStartAngle',
offOver: 'camHelicalOffsetOverride',
entry: 'camHelicalEntry',
entryOffset: 'camHelicalEntryOffset',
reverse: 'camHelicalReverse',
clockwise:'camHelicalClockwise',
thru: 'camHelicalThru',
forceStartAng:'camHelicalForceStartAngle',
fromTop: 'camHelicalFromStockTop',
@ -549,7 +553,12 @@ export function createPopOps() {
startAng: UC.newInput(LANG.ch_stra_s, {title:LANG.ch_stra_l, convert:UC.toDegsFloat, bound:UC.bound(-360,360),show:() => env.poppedRec.forceStartAng}),
offOver: UC.newInput(LANG.cc_offd_s, {title:LANG.cc_offd_l, convert:UC.toFloat, units:true, bound:UC.bound(0,Infinity)}),
sep: UC.newBlank({class:"pop-sep"}),
finish: UC.newBoolean(LANG.ch_fini_s,undefined, { title:LANG.ch_fini_l }),
entry: UC.newBoolean(LANG.ch_entr_s,undefined, {title:LANG.ch_entr_l}),
entryOffset: UC.newInput(LANG.ch_ento_s, {title:LANG.ch_ento_l, convert:UC.toFloat, units:true, show:() => env.poppedRec.entry}),
reverse: UC.newBoolean(LANG.ch_rvrs_s,undefined, {title:LANG.ch_rvrs_l}),
clockwise:UC.newBoolean(LANG.ch_clkw_s,undefined, {title:LANG.ch_clkw_l}),
sep: UC.newBlank({class:"pop-sep"}),
finish: UC.newBoolean(LANG.ch_fini_s,undefined, { title:LANG.ch_fini_l ,show: ()=>!env.poppedRec.reverse}),
forceStartAng: UC.newBoolean(LANG.ch_fsta_s, undefined, {title:LANG.ch_fsta_l }),
fromTop: UC.newBoolean(LANG.cd_ftop_s,undefined, {title:LANG.cd_ftop_l}),
sep: UC.newBlank({class:"pop-sep"}),

View file

@ -24,6 +24,11 @@ export class OpHelical extends CamOp {
down,
thru,
finish,
clockwise,
reverse,
entry,
entryOffset,
} = op;
let {stock} = settings
@ -59,7 +64,7 @@ export class OpHelical extends CamOp {
let radAdd,
zBottom = zmin - thru,
clockwise = true,
numSegs = faces.length / 2,
poly = newPolygon().setOpen();
@ -122,7 +127,8 @@ export class OpHelical extends CamOp {
let toBottom = currentZ - zBottom,
ofFull = toBottom / down,
ofCircle = ofFull * (2 * Math.PI),
finalAngle = startAngle + ofCircle,
cwMultiplier = clockwise ? -1 : 1,
finalAngle = startAngle + (ofCircle*cwMultiplier),
finalEnd = center
.clone()
.setZ(zBottom)
@ -134,19 +140,75 @@ export class OpHelical extends CamOp {
)
);
// console.log({down,toBottom,ofFull,ofCircle,finalAngle,finalEnd});
console.log({down,toBottom,ofFull,ofCircle,startAngle,finalAngle,finalEnd});
//circle down to final point
poly.addPoints(
arcToPath(startPoint.setZ(currentZ), finalEnd, numSegs , {
clockwise: !clockwise,
clockwise,
radius,
center,
})
);
//if settings dictate, do a full circle at the bottom
if(finish){
//if starting at the bottom, reverse poly
if (reverse){
poly.reverse();
}
if ( entry ){
//get first z of poly to use for entry
let firstZ = poly.first().z;
//create new pointArray
let entry =[newPoint(0,0,0)];
//add center point
let entryCenter = center.clone().setZ(firstZ)
console.log({firstZ,entry,})
//if doing a curved enter, add more
if ( entryOffset > 0 ){
if(entryOffset > radius){
console.error("entryOffset must be less than radius of helix");
}else{
//calculate entry center
let lineOut = radius - entryOffset;
let centerOffset = (entryOffset**2 + 2*entryOffset*lineOut) / (2*(entryOffset + lineOut));
//add entry points
entry.push(...
newPoint(0,-lineOut,0),
arcToPath(
newPoint(0,-lineOut,0),
newPoint(radius,0,0),
128,
{
clockwise:false,
radius:lineOut,
center:newPoint(centerOffset,0,0)
}
),
newPoint(radius,0,0),
)
}
}
//for each point
entry = entry.map(p => {
//rotate by start angle
// add to hole center
// TODO: there's totally a way to do this with a matrix
p.y *= clockwise ? 1 : -1
p.rotate(startAngle)
return p.add(entryCenter)
})
//append to start of poly
poly = newPolygon().setOpen().addPoints(entry).addPoints(poly.points);
}
//if doing a finish pass, do a full circle at the bottom
if(finish && !reverse){
poly.addPoints(
arcToPath(finalEnd, finalEnd, numSegs, {
clockwise,

View file

@ -619,7 +619,14 @@ self.lang['en-us'] = {
ch_selc_l: ["select a cylinder face", "inner holes that are too small","will be ignored."],
ch_fini_s: "bottom finish pass",
ch_fini_l: ["trace a circle at bottom of helix","used for hole clearing"],
ch_entr_s: "enter from center",
ch_entr_l: ["start cut from center of cylinder","gently arcing in horisontaly", "instead of plunging"],
ch_ento_s: "center entry offset",
ch_ento_l: ["offset from path for curved entry","usually thread depth if threadmilling","in workspace units","0 for a linear entry"],
ch_rvrs_s: "reverse",
ch_rvrs_l: ["reverse helical z-axis direction","low-Z to high-Z when checked","useful for thread milling","not recomended for other operations"],
ch_clkw_s: "clockwise",
ch_clkw_l: ["reverse helical rotation around cylinder","clockwise when checked"],
// CNC FLIP
cf_menu: "flip",