Add used filament to gcode file

Hi,

I am trying to read printing information for automatic processing from the gcode files.
I am interested in printing time and used filament weight for further calculations.

I found the printing time in the HEADER_BLOCK_START (see sample below) but I didn’t find anything about the used filament weight.

It would be really helpful to add the weight in g and possible the filament length in m to the header information

; HEADER_BLOCK_START
; BambuStudio 01.08.04.51
; model printing time: 1d 8h 29m 45s; total estimated time: 1d 8h 35m 31s
; total layer number: 1400
; model label id: 819
; filament_density: 1.25
; filament_diameter: 1.75
; max_z_height: 112.12
; HEADER_BLOCK_END

If you loop through every line of the GCODE and process all of the G0,G1,G2 and G3 commands, adding up (or subtracting) the E field values you can get the total length (or length per colour if you also take into account the tool change Tx commands).

Weight should then be fairly easily derivable from length, diameter and density.

More detailed printing time can also be derived too if you take into account the speed change commands and tool change times.

1 Like

Was browsing the Bambu Studio pull requests and it seems this is in the pipeline.

4 Likes

Thank you for your link. Yes this seems to be exactly what I am looking for :smiley: