appliedengdesign / vscode-gcode-syntax

G Code Language Extension for Visual Studio Code. Turn VSCode into a fully capable G-Code editor, including language support & more.
MIT License
86 stars 25 forks source link

Code Folding in Tree if 3dp and Layer Comments in file #51

Open tyeth opened 2 years ago

tyeth commented 2 years ago

Suggest a Feature you'd like to see

I wish that my 3d printing gcode files would load in treeview happily. I don't think it serves much purpose, so maybe it could just be disabled instead in 3d printing mode.

The files I use are silly sizes (line count) and include a comment that is a base64 encoded image (64kb) so also silly line length. I wondered while reading the closed issue #23 if it couldn't be more gracefully handled if the file contains Layer markers as comments. If that was the case then the tree could collapse the commands under sections based on layer number.

Additional context It's worth noting that octoprint (or maybe one of its plugins) has a couple of regular expressions to match the majority of slicers / gcode flavours regarding layer comments.

Sample file header (from Luban i.e. Cura) and first few lines of skirt / layer zero:

;Header Start

;FLAVOR:Marlin
;TIME:6666
;Filament used: 0m
;Layer height: 0.24
;MINX:2.14748e+06
;MINY:2.14748e+06
;MINZ:2.14748e+06
;MAXX:-2.14748e+06
;MAXY:-2.14748e+06
;MAXZ:-2.14748e+06

;header_type: 3dp
;tool_head: singleExtruderToolheadForSM2
;machine: A350
;thumbnail: data:image/png;base64,iVBORw0KGgoAAAANg+KikMEREAEREA*****TRUNCATED_64K*****IgAiIgAiIgAj0QeD/AAcGNfSAwHBtAAAAAElFTkSuQmCC
;file_total_lines: 67331
;estimated_time(s): 7364.81
;nozzle_temperature(°C): 245
;nozzle_1_temperature(°C): -1
;nozzle_0_diameter(mm): 0.4
;nozzle_1_diameter(mm): -1
;build_plate_temperature(°C): 60
;work_speed(mm/minute): 3600
;max_x(mm): 499.5
;max_y(mm): 499.5
;max_z(mm): 999
;min_x(mm): -499.5
;min_y(mm): -499.5
;min_z(mm): 0
;layer_number: 145
;layer_height: 0.24
;matierial_weight: 8.335360984415162
;matierial_length: 2.79471
;nozzle_0_material: PLA-LW
;nozzle_1_material: null

;Header End

; G-code for 3dp engraving
; Generated by Snapmaker Luban 4.4.0
; Sat Oct 01 2022 14:1:12

T0
M82 ;absolute extrusion mode
;Start GCode begin
M104 S165
M140 S60
G28 ;home
G90 ;absolute positioning
G1 X-10 Y-10 F3000
G1 Z0 F1800
M190 S60
M104 S245
M190 S65
M109 S245;Wait for Hotend Temperature
G92 E0
G1 E20 F200
G92 E0
;Start GCode end
G92 E0
G92 E0
;LAYER_COUNT:145
;LAYER:0
M107
G0 F1296 X134.252 Y139.045 Z0.28
;TYPE:SKIRT
G1 F1080 X134.836 Y138.524 E0.01749
G1 X135.276 Y138.205 E0.02964
G1 X136.038 Y137.727 E0.04974
mikecentola commented 1 year ago

Hey @tyeth I like those ideas. I'm planning a major update to the extension for v0.8.0 and working towards a 1.0 release that takes more advantage of the machine type choice and possibly even uses a comment at the beginning of the file to dictate to the extension what type of machine tool the code is for.

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity.