@@ -298,7 +298,18 @@ def preview_gcode(file_id):
|
||||
|
||||
content = "File not found or not ready."
|
||||
line_count = 0
|
||||
|
||||
time_info = "-"
|
||||
layer1_time = "-"
|
||||
filament_used = "-"
|
||||
|
||||
if os.path.exists(filepath):
|
||||
from app.utils.gcode_parser import get_gcode_metadata
|
||||
metadata = get_gcode_metadata(filepath)
|
||||
time_info = metadata.get('print_time', '-')
|
||||
layer1_time = metadata.get('first_layer_time', '-')
|
||||
filament_used = metadata.get('filament_used', '-')
|
||||
|
||||
with open(filepath, 'r') as f:
|
||||
lines = f.readlines()
|
||||
line_count = len(lines)
|
||||
@@ -313,7 +324,8 @@ def preview_gcode(file_id):
|
||||
configs = {c.key: c.value for c in SystemConfig.query.all()}
|
||||
offset_x = float(configs.get('offset_x', '0.0'))
|
||||
offset_y = float(configs.get('offset_y', '0.0'))
|
||||
return render_template('slice/gcode_preview.html', file=print_file, content=content, line_count=line_count, machine_width=w, machine_depth=h, machine_height=hd, offset_x=offset_x, offset_y=offset_y)
|
||||
return render_template('slice/gcode_preview.html', file=print_file, content=content, line_count=line_count, machine_width=w, machine_depth=h, machine_height=hd, offset_x=offset_x, offset_y=offset_y,
|
||||
time_info=time_info, layer1_time=layer1_time, filament_used=filament_used)
|
||||
|
||||
@main_bp.route('/delete_file/<int:file_id>', methods=['POST'])
|
||||
@login_required
|
||||
|
||||
Reference in New Issue
Block a user