How to get duration and filament usage on CLI?
 
Notifications
Clear all

How to get duration and filament usage on CLI?  

  RSS
Nia
 Nia
(@nia)
Member
How to get duration and filament usage on CLI?

I'm trying to use the prusa-slicer cli interface to generate time and filament usage estimates for a lot of stl files in a big project of mine.

I can slice the stl files successfully, but I don't see any ways to get the resulting time and filament usage on stdout and didn't spot anything in the help output.

Any hints?

Best Answer by Diem:

One workaround is to include it in the gcode file name with 

--output-filename-format

(you will need to use --help-fff if you don't see this in your -help output.)

Or, if you want to capture the info for a database the values are in every text format g-code file in the comment section at the end.  So you could pipe the output file through grep or use a custom post-processing script...

Cheerio,

Posted : 12/03/2026 8:32 pm
Diem
 Diem
(@diem)
Illustrious Member

One workaround is to include it in the gcode file name with 

--output-filename-format

(you will need to use --help-fff if you don't see this in your -help output.)

Or, if you want to capture the info for a database the values are in every text format g-code file in the comment section at the end.  So you could pipe the output file through grep or use a custom post-processing script...

Cheerio,

Posted : 13/03/2026 3:33 am
1 people liked
Nia
 Nia
(@nia)
Member
Topic starter answered:
RE: How to get duration and filament usage on CLI?

Great, thanks. I'll pull it out of the comments of the gcode file!

Posted : 13/03/2026 4:02 pm
hyiger
(@hyiger)
Famed Member
RE:

I also did this for my g-code library. There is a function called estimate_print which will return an object that encapsulates time, length and weight. It's in Python. If not comfortable with Python REPL I could be convinced to create shell script (or PowerShell for Windows)

pip install gcode-lib
import gcode_lib as gl

# Load and estimate

 # Works with both binary and ascii gcode
gf = gl.load("my_print.bgcode")

 # auto-detect filament type
est = gl.estimate_print(gf.lines)

print(f"Print time:      {est.time_hms} ({est.time_seconds:.0f}s)")
print(f"Filament length: {est.filament_length_m:.2f} m")
print(f"Filament weight: {est.filament_weight_g:.1f} g")

# Use a different filament type
est = gl.estimate_print(gf.lines, filament_type="PETG")

# Or specify density and diameter directly
est = gl.estimate_print(gf.lines, filament_density=1.27, filament_diameter=1.75)

 

 

 

Posted : 14/03/2026 5:31 pm
Nia
 Nia
(@nia)
Member
Topic starter answered:
RE: How to get duration and filament usage on CLI?

interesting, thanks for sharing. my python script now just calls prusa-slicer, then reads those comments. that's enough for me for now, I'll keep it in the back of my mind in case I need more gcode related things in my code tho.

Posted : 14/03/2026 8:51 pm
Share: