compensate for cam origin offset on export / import

This commit is contained in:
Stewart Allen 2025-09-04 20:56:35 -04:00
commit 06459f18b8
2 changed files with 8 additions and 8 deletions

View file

@ -53,8 +53,6 @@ export function cam_export(print, online) {
lasering = false,
laserOp,
stock = settings.stock || {},
ztOff = stock.z - widget.track.top,
bounds = widget.getBoundingBox(),
zmax = stock.z,
runbox = {
max: { x: -Infinity, y: -Infinity, z: -Infinity },
@ -411,7 +409,7 @@ export function cam_export(print, online) {
// collect tool info to add to header
let toolz = {}, ctool;
const isOffset = offset && (offset.x || offset.y);
const isOffset = offset && (offset.x || offset.y || offset.z);
// remap points as necessary for origins, offsets, inversions
print.output.forEach(layer => {
if (!Array.isArray(layer)) {
@ -430,8 +428,9 @@ export function cam_export(print, online) {
// ensure not point is modified twice
point.mod = 1;
if (isOffset) {
point.x += offset.x;
point.y += offset.y;
point.x += offset.x ?? 0;
point.y += offset.y ?? 0;
point.z -= offset.z ?? 0;
}
if (scale) {
point.x *= scale.x;

View file

@ -546,11 +546,12 @@ const dispatch = {
parse(args, send) {
const { settings, code, type } = args;
const { process } = settings;
const origin = settings.origin;
const offset = {
x: origin.x,
y: -origin.y,
z: origin.z
x: origin.x - (process.camOriginOffX ?? 0),
y: -origin.y - (process.camOriginOffY ?? 0),
z: origin.z - (process.camOriginOffZ ?? 0)
};
const device = settings.device;
const print = current.print = newPrint(settings, Object.values(wcache));