comments on bambu's object annotation / cancellation in gcode

This commit is contained in:
Stewart Allen 2025-02-13 18:02:28 -05:00
commit 596c5f12f2
2 changed files with 17 additions and 9 deletions

View file

@ -136,6 +136,19 @@ FDM.export = function(print, online, ondone, ondebug) {
}
subst.tool_count = tools_used.length;
// encodes an array offset as a single "on" bit in an
// 8 byte array then converts the array to base64 which
// is what Bambu's M624 uses to flag an object as currently
// being printed. the array is presented at the top of the
// gcode as a comment: "; model label id: {model_labels}"
function encodeBitOffset(index) {
let bytes = new Uint8Array(8);
let byteIndex = Math.floor(index / 8);
let bitPosition = index % 8;
bytes[byteIndex] |= (1 << bitPosition);
return btoa(String.fromCharCode(...bytes));
}
function setTempFanSpeed(tempSpeed) {
if (tempSpeed > 0) {
fanSpeedSave = fanSpeedSave >= 0 ? fanSpeedSave : fanSpeed;
@ -595,14 +608,6 @@ FDM.export = function(print, online, ondone, ondebug) {
moveTo({z:zpos}, seekMMM);
}
function encodeOffset(index) {
let bytes = new Uint8Array(8);
let byteIndex = Math.floor(index / 8);
let bitPosition = index % 8;
bytes[byteIndex] |= (1 << bitPosition);
return btoa(String.fromCharCode(...bytes));
}
let cwidget;
// iterate through layer outputs
for (pidx=0; pidx<path.length; pidx++) {
@ -618,7 +623,7 @@ FDM.export = function(print, online, ondone, ondebug) {
}
if (out.widget) {
let off = model_labels.indexOf(out.widget.track.grid_id);
let b64 = encodeOffset(off);
let b64 = encodeBitOffset(off);
append(`; start object id: ${out.widget.track.grid_id}`);
isBambu && append(`M624 ${b64}`);
}

View file

@ -635,6 +635,9 @@ function exportGCodeDialog(gcode, sections, info, names) {
' </header>',
' <plate>',
' <metadata key="index" value="1"/>',
// setting this value allows for the printer to error out if
// the gcode / 3mf was intended for a different target type.
// leaving it blank bypasses the check
// ` <metadata key="printer_model_id" value="${ptype}"/>`,
` <metadata key="nozzle_diameters" value="${nozzle0}"/>`,
' <metadata key="timelapse_type" value="0"/>',