I'm working on building a tool to generate G-code (a simpler slicer), and I'm trying to calculate how much filament should be extruded per movement.

Is there a standard calculation for this? Something like:

layer height * flow % * extruder diameter * distance 

How does Ultimaker Cura calculate this?


1 Answer 1


Basically, all movements are (small) straight lines, the volume of a straight line is easily calculated as you already guessed.

To calculate the volume to be extruded you multiply the following parameters:

  • the layer height (h)
  • flow modifier (e.g. as percentage) (SF)
  • extruder nozzle diameter (dn) (or extruder line width if different from nozzle diameter)
  • distance of the straight line (l)

With this volume you can calculate how much filament you need to extrude. To get the length (thus the length defined by the E parameter), divide the obtained volume by surface area of your used filament by:

  • π * (filament radius)2 or alternatively π /4 * (filament diameter)2 = (π /4 * df2)

To sum up, the value of E is given by:

$$ E_{value} = \frac{h \times {SF} \times d_{n} \times l}{\frac{\pi}{4}d_{f}^2} = \frac{4 \times h \times {SF} \times d_{n} \times l}{\pi \times d_{f}^2} $$

  • $\begingroup$ Ultimately the volumetric extruder advance is modelled here just as the volume of a cube. Where there is a little bit of interesting room for variation is how you model the start/stop of the line, where it's not a flat edge but rounded. $\endgroup$ Commented Feb 14, 2023 at 13:10
  • $\begingroup$ I've taken the begin and end in consideration once, it doesn't make a real difference. (Unless you have very short lines to fill...) $\endgroup$
    – 0scar
    Commented Feb 14, 2023 at 16:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .