change default tool change methods for fdm

This commit is contained in:
Stewart Allen 2025-02-18 18:37:02 -05:00
commit a7363732ac
43 changed files with 150 additions and 270 deletions

View file

@ -18,7 +18,7 @@ FDM.export = function(print, online, ondone, ondebug) {
const { bounds, controller, device, process, filter, mode } = settings;
const { extruders, fwRetract } = device;
const { bedWidth, bedDepth, bedRound, bedBelt, maxHeight } = device;
const { gcodeFan, gcodeLayer, gcodeTrack, gcodePause, gcodeFeature } = device;
const { gcodeFan, gcodeLayer, gcodeTrack, gcodePause, gcodeFeature, gcodeChange } = device;
let model_labels = [];
for (let widget of widgets) {
@ -642,10 +642,7 @@ FDM.export = function(print, online, ondone, ondebug) {
// look for extruder change, run scripts, recalc emit factor
if (out.tool !== undefined && out.tool != tool) {
let macro_deselect = extruder.extDeselect.length ? extruder.extDeselect : extruders[0].extDeselect;
let macro_select = extruder.extSelect.length ? extruder.extSelect : extruders[0].extSelect;
segments.push({emitted, tool});
appendAllSub(macro_deselect);
subst.last_tool = tool;
tool = out.tool;
subst.nozzle = subst.tool = tool;
@ -657,7 +654,7 @@ FDM.export = function(print, online, ondone, ondebug) {
extruder.extFilament,
path.layer === 0 ?
(process.firstSliceHeight || process.sliceHeight) : path.height);
appendAllSub(macro_select);
appendAllSub(gcodeChange ?? [ "T{tool}" ]);
}
// if no point in output, it's a dwell command

View file

@ -264,7 +264,7 @@ FDM.prepare = async function(widgets, settings, update) {
// find max layers (for updates)
// generate list of used extruders for purge blocks
for (let widget of widgets) {
let extruder = widget.anno.extruder || 0;
let extruder = widget.anno.extruder ?? 0;
if (!extruders[extruder]) {
extruders[extruder] = {};
extcount++;

View file

@ -890,7 +890,7 @@ FDM.slice = function(settings, widget, onupdate, ondone) {
}
nu.push(nuSlice);
let ti = 0;
for (let top of slice.tops) {
for (let top of slice.tops || []) {
let nuTop = nuSlice.tops[ti++];
nuTop.shells = [];
top.shells = top.shells.filter((s,i) => {
@ -907,7 +907,7 @@ FDM.slice = function(settings, widget, onupdate, ondone) {
cap.z += (slice.height * 0.75);
cap.height = (slice.height / 2);
nu.push(cap);
cap.tops.forEach((top, i) => {
cap.tops?.forEach((top, i) => {
top.shells = nuSlice.tops[i].shells.clone();
});
}