add lathe axis reset macro

This commit is contained in:
Stewart Allen 2025-12-10 18:48:51 -05:00
commit b5a2402a9a
4 changed files with 10 additions and 11 deletions

View file

@ -511,6 +511,7 @@ export const conf = {
camLaserZMax: 0, camLaserZMax: 0,
camLaserZMin: 0, camLaserZMin: 0,
camLatheAngle: 1, camLatheAngle: 1,
camLatheAxisReset: ["G92.4 A0 R0"],
camLatheLinear: true, camLatheLinear: true,
camLatheOver: 0.1, camLatheOver: 0.1,
camLatheSpeed: 500, camLatheSpeed: 500,

View file

@ -349,10 +349,10 @@ export function createPopOps() {
leave: 'camContourLeave', leave: 'camContourLeave',
linear: 'camLatheLinear', linear: 'camLatheLinear',
offStart: 'camLatheOffStart', offStart: 'camLatheOffStart',
offEnd: 'camLatheOffEnd' offEnd: 'camLatheOffEnd',
axisreset: 'camLatheAxisReset'
}).inputs = { }).inputs = {
tool: UC.newSelect(LANG.cc_tool, {}, "tools"), tool: UC.newSelect(LANG.cc_tool, {}, "tools"),
// axis: UC.newSelect(LANG.cd_axis, {}, "xyaxis"),
sep: UC.newBlank({ class: "pop-sep" }), sep: UC.newBlank({ class: "pop-sep" }),
spindle: UC.newInput(LANG.cc_spnd_s, { title: LANG.cc_spnd_l, convert: toInt, show: hasSpindle }), spindle: UC.newInput(LANG.cc_spnd_s, { title: LANG.cc_spnd_l, convert: toInt, show: hasSpindle }),
rate: UC.newInput(LANG.cc_feed_s, { title: LANG.cc_feed_l, convert: toInt, units }), rate: UC.newInput(LANG.cc_feed_s, { title: LANG.cc_feed_l, convert: toInt, units }),
@ -367,12 +367,12 @@ export function createPopOps() {
leave: UC.newInput(LANG.cf_leav_s, { title: LANG.cf_leav_l, convert: toFloat, bound: UC.bound(0, 100) }), leave: UC.newInput(LANG.cf_leav_s, { title: LANG.cf_leav_l, convert: toFloat, bound: UC.bound(0, 100) }),
sep: UC.newBlank({ class: "pop-sep" }), sep: UC.newBlank({ class: "pop-sep" }),
linear: UC.newBoolean(LANG.ci_line_s, undefined, { title: LANG.ci_line_l }), linear: UC.newBoolean(LANG.ci_line_s, undefined, { title: LANG.ci_line_l }),
// filter: UC.newRow([ UC.newButton(LANG.filter, contourFilter) ], {class:"ext-buttons f-row"}) axisreset: UC.newRow([ UC.newButton("axis reset", gcodeEditor('Rotary (A) Axis Reset Macro', 'axisreset')) ], { class: "ext-buttons f-row" })
}; };
function canDogBones() { function canDogBones() {
if (!env.poppedRec) return false; if (!env.poppedRec) return false;
return env.poppedRec.mode === 'follow';// && env.poppedRec.offset && env.poppedRec.offset !== 'none'; return env.poppedRec.mode === 'follow';
} }
function canDogBonesRev() { function canDogBonesRev() {

View file

@ -1,7 +1,6 @@
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */ /** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
import { CamOp } from './op.js'; import { CamOp } from './op.js';
import { Tool } from './tool.js';
import { generate as topo4_generate } from './topo4.js'; import { generate as topo4_generate } from './topo4.js';
import { newPoint } from '../../../geo/point.js'; import { newPoint } from '../../../geo/point.js';
@ -55,7 +54,8 @@ class OpLathe extends CamOp {
prepare(ops, progress) { prepare(ops, progress) {
let { op, slices, topo } = this; let { op, slices, topo } = this;
let { camOut, getLastPoint, newLayer, setContouring, setNextIsMove, zSafe } = ops; let { axisreset } = op;
let { camOut, newLayer, setContouring, setNextIsMove, zSafe } = ops;
let rez = topo.resolution; let rez = topo.resolution;
@ -80,10 +80,8 @@ class OpLathe extends CamOp {
} }
// move to safe height and reset A axis // move to safe height and reset A axis
let last = getLastPoint();
let amax = (Math.round(last.a / 360) * 360).round(2);
newLayer(); newLayer();
ops.addGCode([`G0 Z${zSafe.round(2)}`, `G0 A${amax}`, "G92 A0"]); ops.addGCode([`G0 Z${zSafe.round(2)}`, axisreset.join('\n') ?? "G92.4 A0 R0"]);
} }
} }

View file

@ -159,7 +159,7 @@ export class Topo {
} }
async sliceGPU(onupdate) { async sliceGPU(onupdate) {
const { angle, diam, linear, offStart, offEnd, resolution, tool, units, vertices, zBottom } = this; const { angle, diam, leave, linear, offStart, offEnd, resolution, tool, units, vertices, zBottom } = this;
// invert tool Z offset for gpu code // invert tool Z offset for gpu code
let toolBounds = new THREE.Box3() let toolBounds = new THREE.Box3()
@ -217,7 +217,7 @@ export class Topo {
let xoff = boundsOverride.min.x; let xoff = boundsOverride.min.x;
let rows = []; let rows = [];
for (let i=0; i<numStrips; i++) { for (let i=0; i<numStrips; i++) {
let points = Array.from(strips[i].pathData).map((v,j) => newPoint(j * xmult + xoff, 0, v).setA(-i * degPerRow)); let points = Array.from(strips[i].pathData).map((v,j) => newPoint(j * xmult + xoff, 0, v + leave).setA(-i * degPerRow));
rows.push(points); rows.push(points);
} }
if (linear) { if (linear) {