🐛 GCode analysis & viewer: Assume bed at Z 0.0

People might not actually always have a home command in their GCODE
files, so let's just depend on the so far pretty universal truth that
printers have a bed at z=0 and that is just always the lowest Z of a
printed object. And just in case, let's make this value configurable
because the printer gods only know what some people might come up with
in terms of experimental printer mechanics that end up with negative z
coordinates or a bed at z=100.

Closes #4036
This commit is contained in:
Gina Häußge committed 2021-03-04 12:49:13 +01:00
1 parent ffea45ce54
commit 4c4570e2e1
9 files changed
+58 -18

No files matched your search

@@ -365,7 +365,8 @@ $(function () {
onLayerSelected: self._onLayerSelected,
bed: self._retrieveBedDimensions(),
toolOffsets: self._retrieveToolOffsets(),
invertAxes: self._retrieveAxesConfiguration()
invertAxes: self._retrieveAxesConfiguration(),
bedZ: self.settings.settings.gcodeAnalysis.bedZ()
});
if (!initResult) {
@@ -39,7 +39,8 @@ GCODE.gCodeReader = (function () {
centeredOrigin: undefined
},
ignoreOutsideBed: false,
g90InfluencesExtruder: false
g90InfluencesExtruder: false,
bedZ: 0
};
var percentageTree = undefined;
@@ -166,7 +167,8 @@ GCODE.gCodeReader = (function () {
toolOffsets: gCodeOptions["toolOffsets"],
bed: gCodeOptions["bed"],
ignoreOutsideBed: gCodeOptions["ignoreOutsideBed"],
g90InfluencesExtruder: gCodeOptions["g90InfluencesExtruder"]
g90InfluencesExtruder: gCodeOptions["g90InfluencesExtruder"],
bedZ: gCodeOptions["bedZ"]
}
}
});
@@ -174,11 +176,11 @@ GCODE.gCodeReader = (function () {
setOption: function (options) {
var dirty = false;
for (var opt in options) {
if (options[opt] === undefined) continue;
dirty = dirty || gCodeOptions[opt] != options[opt];
gCodeOptions[opt] = options[opt];
}
_.forOwn(options, function (value, key) {
if (value === undefined) return;
dirty = dirty || gCodeOptions[key] !== value;
gCodeOptions[key] = value;
});
if (dirty) {
if (model && model.length > 0) this.passDataToRenderer();
}
@@ -156,7 +156,8 @@ GCODE.ui = (function () {
});
GCODE.gCodeReader.setOption({
toolOffsets: options.toolOffsets,
bed: options.bed
bed: options.bed,
bedZ: options.bedZ
});
GCODE.renderer.render(0, 0);
@@ -715,6 +715,7 @@ var parseGCode = function (message) {
bed = message.options.bed;
ignoreOutsideBed = message.options.ignoreOutsideBed;
g90InfluencesExtruder = message.options.g90InfluencesExtruder;
boundingBox.minZ = min.z = message.options.bedZ;
doParse();
gcode = [];