Added docs-tfg and implemented functionality of warning in case object is bigger than printer area
This commit is contained in:
1 parent
dedadbc9ac
commit
caf4e84ab2
1889 files changed
+491678
-2
No files matched your search
@@ -17,6 +17,8 @@ from octoprint.events import Events, eventManager
|
||||
|
||||
import octoprint.util.gcodeInterpreter as gcodeInterpreter
|
||||
|
||||
#Added to check if object exceeds printing area
|
||||
from octoprint.printer.profile import PrinterProfileManager
|
||||
|
||||
class QueueEntry(collections.namedtuple("QueueEntry", "path, type, location, absolute_path, printer_profile")):
|
||||
"""
|
||||
@@ -258,8 +260,9 @@ class GcodeAnalysisQueue(AbstractAnalysisQueue):
|
||||
|
||||
self._gcode = gcodeInterpreter.gcode()
|
||||
self._gcode.load(self._current.absolute_path, self._current.printer_profile, throttle=throttle_callback)
|
||||
|
||||
|
||||
result = dict()
|
||||
result["warning"]=self._gcode.getWarning()
|
||||
if self._gcode.totalMoveTimeMinute:
|
||||
result["estimatedPrintTime"] = self._gcode.totalMoveTimeMinute * 60
|
||||
if self._gcode.extrusionAmount:
|
||||
|
||||
@@ -327,6 +327,17 @@ $(function() {
|
||||
}
|
||||
}
|
||||
output += gettext("Estimated Print Time") + ": " + formatDuration(data["gcodeAnalysis"]["estimatedPrintTime"]) + "<br>";
|
||||
if(data["gcodeAnalysis"]["warning"])
|
||||
{
|
||||
var warning = "<p>" + gettext("Object exceeds printing area") + "</p>";
|
||||
warning += pnotifyAdditionalInfo("<pre>Object or objects in file '"+data["name"]+"' exceeds the printing area</pre>");
|
||||
new PNotify({
|
||||
title: "Object dimensions",
|
||||
text: warning,
|
||||
type: "warning",
|
||||
hide: false
|
||||
});
|
||||
}
|
||||
}
|
||||
if (data["prints"] && data["prints"]["last"]) {
|
||||
output += gettext("Last Printed") + ": " + formatTimeAgo(data["prints"]["last"]["date"]) + "<br>";
|
||||
@@ -402,11 +413,17 @@ $(function() {
|
||||
if (_.endsWith(filename.toLowerCase(), ".stl")) {
|
||||
self.slicing.show(location, filename);
|
||||
}
|
||||
|
||||
|
||||
if (data.result.done) {
|
||||
$("#gcode_upload_progress .bar").css("width", "0%");
|
||||
$("#gcode_upload_progress").removeClass("progress-striped").removeClass("active");
|
||||
$("#gcode_upload_progress .bar").text("");
|
||||
/*var cadena="";
|
||||
for(var i in data)
|
||||
{
|
||||
cadena+=" "+i+"\t";
|
||||
};*/
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,8 @@ class gcode(object):
|
||||
self.progressCallback = None
|
||||
self._abort = False
|
||||
self._filamentDiameter = 0
|
||||
#Parameters for object size checking
|
||||
self.warn=False
|
||||
|
||||
def load(self, filename, printer_profile, throttle=None):
|
||||
if os.path.isfile(filename):
|
||||
@@ -117,6 +119,13 @@ class gcode(object):
|
||||
z = getCodeFloat(line, 'Z')
|
||||
e = getCodeFloat(line, 'E')
|
||||
f = getCodeFloat(line, 'F')
|
||||
#Check if x,y or z exceeds printing area
|
||||
width=float(printer_profile["volume"]["width"])
|
||||
depth=float(printer_profile["volume"]["depth"])
|
||||
height=float(printer_profile["volume"]["height"])
|
||||
if not self.warn and (x>width or y>depth or z>height):
|
||||
self.warn=True
|
||||
self._logger.warn("Object is bigger than the printing area")
|
||||
oldPos = pos
|
||||
pos = pos[:]
|
||||
if posAbs:
|
||||
@@ -255,6 +264,8 @@ class gcode(object):
|
||||
def _parseCuraProfileString(self, comment, prefix):
|
||||
return {key: value for (key, value) in map(lambda x: x.split("=", 1), zlib.decompress(base64.b64decode(comment[len(prefix):])).split("\b"))}
|
||||
|
||||
def getWarning(self):
|
||||
return self.warn
|
||||
|
||||
def getCodeInt(line, code):
|
||||
n = line.find(code) + 1
|
||||
|
||||
Reference in new issue
Block a user