diff --git a/app/routes/main_routes.py b/app/routes/main_routes.py index b4ac694..a4f551e 100644 --- a/app/routes/main_routes.py +++ b/app/routes/main_routes.py @@ -250,7 +250,12 @@ def download_gcode(file_id): return redirect(url_for('main.files')) gcode_filename = print_file.filename.rsplit('.', 1)[0] + '.gcode' - filepath = os.path.join(current_app.config['UPLOAD_FOLDER'], gcode_filename) + conf = SystemConfig.query.filter_by(key='gcode_upload_folder').first() + gcode_dir = conf.value if (conf and conf.value and os.path.exists(conf.value)) else current_app.config['UPLOAD_FOLDER'] + filepath = os.path.join(gcode_dir, gcode_filename) + if not os.path.exists(filepath): + fallback = os.path.join(current_app.config['UPLOAD_FOLDER'], gcode_filename) + if os.path.exists(fallback): filepath = fallback if os.path.exists(filepath): safe_name = print_file.original_filename.rsplit('.', 1)[0] + '.gcode' @@ -266,7 +271,12 @@ def preview_gcode(file_id): abort(403) gcode_filename = print_file.filename.rsplit('.', 1)[0] + '.gcode' - filepath = os.path.join(current_app.config['UPLOAD_FOLDER'], gcode_filename) + conf = SystemConfig.query.filter_by(key='gcode_upload_folder').first() + gcode_dir = conf.value if (conf and conf.value and os.path.exists(conf.value)) else current_app.config['UPLOAD_FOLDER'] + filepath = os.path.join(gcode_dir, gcode_filename) + if not os.path.exists(filepath): + fallback = os.path.join(current_app.config['UPLOAD_FOLDER'], gcode_filename) + if os.path.exists(fallback): filepath = fallback content = "File not found or not ready." line_count = 0 @@ -293,7 +303,11 @@ def delete_file(file_id): stl_path = os.path.join(current_app.config['UPLOAD_FOLDER'], print_file.filename) gcode_filename = print_file.filename.rsplit('.', 1)[0] + '.gcode' - gcode_path = os.path.join(current_app.config['UPLOAD_FOLDER'], gcode_filename) + conf = SystemConfig.query.filter_by(key='gcode_upload_folder').first() + gcode_dir = conf.value if (conf and conf.value and os.path.exists(conf.value)) else current_app.config['UPLOAD_FOLDER'] + gcode_path = os.path.join(gcode_dir, gcode_filename) + fallback_gcode = os.path.join(current_app.config['UPLOAD_FOLDER'], gcode_filename) + proxy_path = stl_path + '.proxy.stl' if os.path.exists(stl_path): @@ -302,6 +316,8 @@ def delete_file(file_id): os.remove(proxy_path) if os.path.exists(gcode_path): os.remove(gcode_path) + if os.path.exists(fallback_gcode): + os.remove(fallback_gcode) db.session.delete(print_file) db.session.commit() diff --git a/app/templates/slice/plater.html b/app/templates/slice/plater.html index 3af9d78..4b2c313 100644 --- a/app/templates/slice/plater.html +++ b/app/templates/slice/plater.html @@ -866,7 +866,7 @@ function mergeAndSlice() { if (m.userData.geomTrans) { mat.multiply(m.userData.geomTrans); } - const translation = new THREE.Matrix4().makeTranslation((bedWidth / 2) + offsetX, (bedDepth / 2) + offsetY, 0); + const translation = new THREE.Matrix4().makeTranslation(offsetX,offsetY, 0); mat.premultiply(translation); return { file_id: m.userData.fileId,