Merge branch 'dev/printExceedsBed' into devel
This commit is contained in:
commit
e560809f70
3 changed files with 105 additions and 4 deletions
|
|
@ -260,6 +260,8 @@ class GcodeAnalysisQueue(AbstractAnalysisQueue):
|
|||
self._gcode.load(self._current.absolute_path, self._current.printer_profile, throttle=throttle_callback)
|
||||
|
||||
result = dict()
|
||||
result["printingArea"] = {"minX" : self._gcode.minX, "minY" : self._gcode.minY, "minZ" : self._gcode.minZ,
|
||||
"maxX" : self._gcode.maxX, "maxY" : self._gcode.maxY, "maxZ" : self._gcode.maxZ}
|
||||
if self._gcode.totalMoveTimeMinute:
|
||||
result["estimatedPrintTime"] = self._gcode.totalMoveTimeMinute * 60
|
||||
if self._gcode.extrusionAmount:
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ $(function() {
|
|||
self.loginState = parameters[1];
|
||||
self.printerState = parameters[2];
|
||||
self.slicing = parameters[3];
|
||||
self.printerProfiles=parameters[4];
|
||||
|
||||
self.isErrorOrClosed = ko.observable(undefined);
|
||||
self.isOperational = ko.observable(undefined);
|
||||
|
|
@ -288,7 +289,8 @@ $(function() {
|
|||
}
|
||||
OctoPrint.files.select(file.origin, OctoPrint.files.pathForElement(file))
|
||||
.done(function() {
|
||||
if (printAfterLoad) {
|
||||
var withinPrintDimensions = self.evaluatePrintDimensions(file, true);
|
||||
if (withinPrintDimensions && printAfterLoad) {
|
||||
OctoPrint.job.start();
|
||||
}
|
||||
});
|
||||
|
|
@ -410,6 +412,17 @@ $(function() {
|
|||
self.getAdditionalData = function(data) {
|
||||
var output = "";
|
||||
if (data["gcodeAnalysis"]) {
|
||||
if (data["gcodeAnalysis"]["printingArea"]) {
|
||||
var area = data["gcodeAnalysis"]["printingArea"];
|
||||
var dimensions = {
|
||||
width: area["maxX"] - area["minX"],
|
||||
depth: area["maxY"] - area["minY"],
|
||||
height: area["maxZ"] - area["minZ"]
|
||||
};
|
||||
|
||||
output += gettext("Model Size") + ": " + _.sprintf("%(width).2fmm × %(depth).2fmm × %(height).2fmm", dimensions);
|
||||
output += "<br>";
|
||||
}
|
||||
if (data["gcodeAnalysis"]["filament"] && typeof(data["gcodeAnalysis"]["filament"]) == "object") {
|
||||
var filament = data["gcodeAnalysis"]["filament"];
|
||||
if (_.keys(filament).length == 1) {
|
||||
|
|
@ -433,6 +446,80 @@ $(function() {
|
|||
return output;
|
||||
};
|
||||
|
||||
self.evaluatePrintDimensions = function(data, notify) {
|
||||
var printingArea = data["gcodeAnalysis"]["printingArea"];
|
||||
if (!printingArea) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var printerProfile = self.printerProfiles.currentProfileData();
|
||||
if (!printerProfile) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var volumeInfo = printerProfile.volume;
|
||||
if (!volumeInfo) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// set print volume boundaries
|
||||
var boundaries = {
|
||||
minX : 0,
|
||||
maxX : volumeInfo.width(),
|
||||
minY : 0,
|
||||
maxY : volumeInfo.depth(),
|
||||
minZ : 0,
|
||||
maxZ : volumeInfo.height()
|
||||
};
|
||||
if (volumeInfo.origin() == "center") {
|
||||
boundaries["maxX"] = volumeInfo.width() / 2;
|
||||
boundaries["minX"] = -1 * boundaries["maxX"];
|
||||
boundaries["maxY"] = volumeInfo.depth() / 2;
|
||||
boundaries["minY"] = -1 * boundaries["maxY"];
|
||||
}
|
||||
|
||||
// model not within bounds, we need to prepare a warning
|
||||
var warning = "<p>" + _.sprintf(gettext("Object in %(name)s exceeds the print volume of the currently selected printer profile, be careful when printing this."), data) + "</p>";
|
||||
var info = "";
|
||||
|
||||
var formatData = {
|
||||
profile: boundaries,
|
||||
object: printingArea
|
||||
};
|
||||
|
||||
info += _.sprintf(gettext("Object's bounding box: (%(object.minX).2f, %(object.minY).2f, %(object.minZ).2f) × (%(object.maxX).2f, %(object.maxY).2f, %(object.maxZ).2f)"), formatData);
|
||||
info += "<br>";
|
||||
info += _.sprintf(gettext("Print volume: (%(profile.minX).2f, %(profile.minY).2f, %(profile.minZ).2f) × (%(profile.maxX).2f, %(profile.maxY).2f, %(profile.maxZ).2f)"), formatData);
|
||||
|
||||
// find exceeded dimensions
|
||||
if (printingArea["minX"] < boundaries["minX"] || printingArea["maxX"] > boundaries["maxX"]) {
|
||||
info += gettext("<br>Object exceeds print volume in width.");
|
||||
}
|
||||
if (printingArea["minY"] < boundaries["minY"] || printingArea["maxY"] > boundaries["maxY"]) {
|
||||
info += gettext("<br>Object exceeds print volume in depth.");
|
||||
}
|
||||
if (printingArea["minZ"] < boundaries["minZ"] || printingArea["maxZ"] > boundaries["maxZ"]) {
|
||||
info += gettext("<br>Object exceeds print volume in height.");
|
||||
}
|
||||
|
||||
//warn user
|
||||
if (info != "") {
|
||||
if (notify) {
|
||||
warning += pnotifyAdditionalInfo(info);
|
||||
|
||||
new PNotify({
|
||||
title: gettext("Object doesn't fit print volume"),
|
||||
text: warning,
|
||||
type: "warning",
|
||||
hide: false
|
||||
});
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
self.performSearch = function(e) {
|
||||
var query = self.searchQuery();
|
||||
if (query !== undefined && query.trim() != "") {
|
||||
|
|
@ -708,7 +795,7 @@ $(function() {
|
|||
|
||||
OCTOPRINT_VIEWMODELS.push([
|
||||
GcodeFilesViewModel,
|
||||
["settingsViewModel", "loginStateViewModel", "printerStateViewModel", "slicingViewModel"],
|
||||
["settingsViewModel", "loginStateViewModel", "printerStateViewModel", "slicingViewModel","printerProfilesViewModel"],
|
||||
["#files_wrapper", "#add_folder_dialog"]
|
||||
]);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ class AnalysisAborted(Exception):
|
|||
class gcode(object):
|
||||
def __init__(self):
|
||||
self._logger = logging.getLogger(__name__)
|
||||
|
||||
self.layerList = None
|
||||
self.extrusionAmount = [0]
|
||||
self.extrusionVolume = [0]
|
||||
|
|
@ -30,6 +29,13 @@ class gcode(object):
|
|||
self.progressCallback = None
|
||||
self._abort = False
|
||||
self._filamentDiameter = 0
|
||||
#Parameters for object size check
|
||||
self.minX=None
|
||||
self.minY=None
|
||||
self.minZ=None
|
||||
self.maxX=None
|
||||
self.maxY=None
|
||||
self.maxZ=None
|
||||
|
||||
def load(self, filename, printer_profile, throttle=None):
|
||||
if os.path.isfile(filename):
|
||||
|
|
@ -143,7 +149,14 @@ class gcode(object):
|
|||
if e is not None:
|
||||
if absoluteE:
|
||||
e -= currentE[currentExtruder]
|
||||
# If move includes extrusion, calculate new min/max coordinates of model
|
||||
if e > 0.0:
|
||||
self.minX = pos[0] if self.minX is None or pos[0] < self.minX else self.minX
|
||||
self.maxX = pos[0] if self.maxX is None or pos[0] > self.maxX else self.maxX
|
||||
self.minY = pos[1] if self.minY is None or pos[1] < self.minY else self.minY
|
||||
self.maxY = pos[1] if self.maxY is None or pos[1] > self.maxY else self.maxY
|
||||
self.minZ = pos[2] if self.minZ is None or pos[2] < self.minZ else self.minZ
|
||||
self.maxZ = pos[2] if self.maxZ is None or pos[2] > self.maxZ else self.maxZ
|
||||
moveType = 'extrude'
|
||||
if e < 0.0:
|
||||
moveType = 'retract'
|
||||
|
|
@ -271,7 +284,6 @@ 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 getCodeInt(line, code):
|
||||
n = line.find(code) + 1
|
||||
if n < 1:
|
||||
|
|
|
|||
Loading…
Reference in a new issue