/CuraExpressionEvaluationPostPro

a cura post processing script for evaluating expressions in g-code

Primary LanguagePythonGNU Lesser General Public License v2.1LGPL-2.1

Contributors Forks Stargazers Issues MIT License


Expression Evaluation Post Pro

a cura post processing script for evaluating arithmetic and logical expressions in g-code

Report Bug · Request Feature

About The Project

This post-processing script allows you to perform math and logic operations in the start and end G-Code. Unlike Slic3r, Cura doesn't support this feature out of the box. With this script, you can evaluate arithmetic and logical expressions, giving you more control over your G-Code and making your workflow smoother.

(back to top)

Getting Started

Prerequisites

Cura version 3.1.0 or newer

Adding Script to Cura

  1. In Cura go to Help > Show Configuraiton Folder
  2. In the Configuration Folder open the scipts folder and paste the ArithmLogicExprEval.py script
  3. Restart Cura

(back to top)

Usage

  1. Click on the Post-Processing button </> next to the Slice Button.
  2. Click Add a script
  3. Choose Arithmetic and Logical Expression Evaluation

Expressions can be defined in start- and end- G-code as well as in other post-processing scripts. When defining expressions in post processing scripts make sure those scripts are executed before this script.

Expressions must be in Python syntax. You can use any arithmetic and logical operators as well as parentheses and decimal points.

For example this start G-code draws a puge line at the Initial Layer Speed. {speed_layer_0} returns the Initial Layer Speed in mm/s. Therefore the expression gives the Initial Layer Speed in mm/min

G1 X0.1 Y20 Z0.3 F5000.0 ; Move to start position
G1 X0.1 Y200.0 Z0.3 F{speed_layer_0}*60 E15 ; Draw the first line
G1 X0.4 Y200.0 Z0.3 F5000.0 ; Move to side a little
G1 X0.4 Y20 Z0.3 F{speed_layer_0}*60 E30 ; Draw the second line

By default expressions in comments are ignored. You can tick the Evaluate Comments checkbox to evaluate expresions in comments.

The result of boolean expressions is represented as binary as this is the typical boolean representation in gcode. You can change the Boolean Representation to text in the options. This doesn't affect the boolean representaion in the expressions. Remeber that python uses text boolean representation (True False).

(back to top)

License

Distributed under the GNU LGPL v2.1 License. See LICENSE for more information.

(back to top)