Added sanity check for extruder selection in gcode files
Any T command targeting a number higher than the value specified in the settings for gcodeAnalysis.maxExtruders (defaults to 10) will be ignored and trigger a warning in the log file. Fix for #539
This commit is contained in:
parent
4d434d36be
commit
7d5c55fc95
2 changed files with 20 additions and 14 deletions
|
|
@ -73,6 +73,9 @@ default_settings = {
|
||||||
"mobileSizeThreshold": 2 * 1024 * 1024, # 2MB
|
"mobileSizeThreshold": 2 * 1024 * 1024, # 2MB
|
||||||
"sizeThreshold": 20 * 1024 * 1024, # 20MB
|
"sizeThreshold": 20 * 1024 * 1024, # 20MB
|
||||||
},
|
},
|
||||||
|
"gcodeAnalysis": {
|
||||||
|
"maxExtruders": 10
|
||||||
|
},
|
||||||
"feature": {
|
"feature": {
|
||||||
"temperatureGraph": True,
|
"temperatureGraph": True,
|
||||||
"waitForStartOnConnect": False,
|
"waitForStartOnConnect": False,
|
||||||
|
|
|
||||||
|
|
@ -195,23 +195,26 @@ class gcode(object):
|
||||||
absoluteE = False
|
absoluteE = False
|
||||||
|
|
||||||
elif T is not None:
|
elif T is not None:
|
||||||
posOffset[0] -= offsets[currentExtruder]["x"] if currentExtruder < len(offsets) else 0
|
if T > settings().getInt(["gcodeAnalysis", "maxExtruders"]):
|
||||||
posOffset[1] -= offsets[currentExtruder]["y"] if currentExtruder < len(offsets) else 0
|
self._logger.warn("GCODE tried to select tool %d, that looks wrong, ignoring for GCODE analysis" % T)
|
||||||
|
else:
|
||||||
|
posOffset[0] -= offsets[currentExtruder]["x"] if currentExtruder < len(offsets) else 0
|
||||||
|
posOffset[1] -= offsets[currentExtruder]["y"] if currentExtruder < len(offsets) else 0
|
||||||
|
|
||||||
currentExtruder = T
|
currentExtruder = T
|
||||||
|
|
||||||
posOffset[0] += offsets[currentExtruder]["x"] if currentExtruder < len(offsets) else 0
|
posOffset[0] += offsets[currentExtruder]["x"] if currentExtruder < len(offsets) else 0
|
||||||
posOffset[1] += offsets[currentExtruder]["y"] if currentExtruder < len(offsets) else 0
|
posOffset[1] += offsets[currentExtruder]["y"] if currentExtruder < len(offsets) else 0
|
||||||
|
|
||||||
if len(currentE) <= currentExtruder:
|
if len(currentE) <= currentExtruder:
|
||||||
for i in range(len(currentE), currentExtruder + 1):
|
for i in range(len(currentE), currentExtruder + 1):
|
||||||
currentE.append(0.0)
|
currentE.append(0.0)
|
||||||
if len(maxExtrusion) <= currentExtruder:
|
if len(maxExtrusion) <= currentExtruder:
|
||||||
for i in range(len(maxExtrusion), currentExtruder + 1):
|
for i in range(len(maxExtrusion), currentExtruder + 1):
|
||||||
maxExtrusion.append(0.0)
|
maxExtrusion.append(0.0)
|
||||||
if len(totalExtrusion) <= currentExtruder:
|
if len(totalExtrusion) <= currentExtruder:
|
||||||
for i in range(len(totalExtrusion), currentExtruder + 1):
|
for i in range(len(totalExtrusion), currentExtruder + 1):
|
||||||
totalExtrusion.append(0.0)
|
totalExtrusion.append(0.0)
|
||||||
|
|
||||||
if self.progressCallback is not None:
|
if self.progressCallback is not None:
|
||||||
self.progressCallback(100.0)
|
self.progressCallback(100.0)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue