<p>Basically, all movements are (small) straight lines, the volume of a straight line is easily calculated as you already guessed.</p>
<p>To calculate the volume to be extruded you multiply the following parameters:</p>
<ul>
<li>the layer height <em>(h)</em></li>
<li>flow modifier (e.g. as percentage) <em>(SF)</em></li>
<li>extruder nozzle diameter <em>(d<sub>n</sub>)</em> (or extruder line width if different from nozzle diameter)</li>
<li>distance of the straight line <em>(l)</em></li>
</ul>
<p>With this volume you can calculate how much filament you need to extrude. To get the length (thus the length defined by the <code>E</code> parameter), divide the obtained volume by surface area of your used filament by:</p>
<ul>
<li>π * (filament radius)<sup>2</sup> or alternatively π /4 * (filament diameter)<sup>2</sup> = (π /4 * d<sub>f</sub><sup>2</sup>)</li>
</ul>
<p>To sum up, the value of E is given by:</p>
<p><span class="math-container">$$ 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} $$</span></p>

CC BY-SA 4.0
2023-02-14T13:10:22.040Z
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.
R.. GitHub STOP HELPING ICE
CC BY-SA 4.0
2023-02-14T16:03:30.987Z
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...)
0scar
CC BY-SA 4.0
2018-07-05T18:32:22.187Z
2023-02-14T16:02:06.267Z
2023-02-14T16:02:06.267Z
0scar
<p>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.</p>

<p>Is there a standard calculation for this? Something like:</p>

<pre><code>layer height * flow % * extruder diameter * distance 
</code></pre>

<p>How does Ultimaker Cura calculate this?</p>

<ultimaker-cura><extrusion>
How is the E argument calculated for a given G1 command?
t. gl.
# How is the E argument calculated for a given G1 command?

(Asked by: username_0 on 2018-07-05)

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?

**Tags:** ultimaker-cura, extrusion


---

## 1 answers

### Answer by username_1 on 2018-07-05. Score: 11 | Accepted answer

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} $$

> **Comments:**
> **username_2**: 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.  
> **username_1**: 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...)  

---

