Skip to content

Commit 8f2b3d1

Browse files
authored
Some formatting
1 parent 9409c5f commit 8f2b3d1

File tree

1 file changed

+34
-36
lines changed

1 file changed

+34
-36
lines changed

src/advanced/conditional-gcode.md

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,64 +2,64 @@
22

33
# Overview
44

5-
Conditional GCode is a powerful feature of Slic3r that allows for arbitrary
6-
math to be done in Custom GCode fields as well as setting conditions for specific statements to appear in output from Custom GCode.
7-
8-
5+
Conditional G-code is a powerful feature of Slic3r that allows for arbitrary
6+
math to be done in Custom G-code fields as well as setting conditions for specific statements to appear in output from Custom G-code.
97

108
# Conditional expressions
119

1210
Conditional expressions has the following syntax:
13-
* {if _expression_}
11+
12+
* `{if _expression_}`
1413

1514
_expression_ may take one of the following forms:
16-
* VARIABLE OPERATOR CONSTANT
17-
* CONSTANT OPERATOR VARIABLE
18-
* {_subexpression_} OPERATOR {_subexpression_}
19-
* OPERATOR _subexpression_
15+
16+
* <VARIABLE> <OPERATOR> <CONSTANT>
17+
* <CONSTANT> <OPERATOR> <VARIABLE>
18+
* `{_subexpression_}` <OPERATOR> `{_subexpression_}`
19+
* <OPERATOR> `_subexpression_`
2020

2121
_subexpression_ has the same forms as _expression_.
2222

2323
If _subexpression_s exist, they are evaluated before any other operators.
2424

2525
Available operators:
26-
* `&&` or `and` - logical AND
27-
* `||` or `or` - logical OR
28-
* `!` or `not` - logical NOT (inversion)
29-
* `^` or `xor` - XOR (exclusive-OR)
30-
* `==` or `equals` - equality comparison.
31-
* `!=` - inequality comparison. To use words, use a subexpression.
32-
* `<` - less than (valid for numbers only)
33-
* `<=` - less than or equal to (valid for numbers only)
34-
* `>` - greater than (valid for numbers only)
35-
* `>=` - greater than or equal to (valid for numbers only)
36-
* Anything supported by exprtk [^1]
37-
* Generic variables and file I/O are not supported.
38-
* Any exprtk expressions that involve `{}`s are not supported.
39-
40-
Available keywords:
41-
* 'false'
42-
* 'true'
43-
44-
To apply a single condition to multiple lines, repeat it once for each line.
26+
27+
* `&&` or `and`: logical AND
28+
* `||` or `or`: logical OR
29+
* `!` or `not`: logical NOT (inversion)
30+
* `^` or `xor`: XOR (exclusive-OR)
31+
* `==` or `equals`: equality comparison
32+
* `!=`: inequality comparison. To use words, use a subexpression.
33+
* `<`: less than (valid for numbers only)
34+
* `<=`: less than or equal to (valid for numbers only)
35+
* `>`: greater than (valid for numbers only)
36+
* `>=`: greater than or equal to (valid for numbers only)
37+
* Anything supported by [exprtk](http://www.partow.net/programming/exprtk/index.html) (except for generic variables, file I/O and expressions that involve `{}`)
38+
39+
The `true` and `false` keywords are available.
40+
41+
To apply a single condition to multiple lines, repeat it once for each line:
42+
4543
````
4644
{if [layer_num] == 10}M104 S210
4745
{if [layer_num] == 10}M600
4846
````
4947

48+
If a conditional expression evaluates to false, all the characters until the end of the line are removed.
49+
If a conditional expression fails to parse, it's silently left untouched.
50+
51+
Expressions may be chained for an implicit AND:
5052

51-
* If a conditional expression evaluates to false, all the characters until the end of the line are removed.
52-
* If a conditional expression fails to parse, it's silently left untouched.
53-
* Expressions may be chained for an implicit AND.
5453
````
5554
{if [layer_num] == 10}{if [temperature_1] != 210}M104 S210
5655
````
5756

5857
## Conventions
58+
5959
* Numerical value of 0 is equivalent to logical `false`. Any nonzero value is considered to be logical `true`.
6060
* `{if { 1 - 1 } }` would result in 0 and thus `false`.
6161

62-
# Value expressions (GCode Math)
62+
# Value expressions (G-code Math)
6363

6464
Any expression enclosed in two curly brackets, but not starting with `{if` is evaluated as an arithmetic expression: `{foo - bar}`.
6565
If evaluation fails, the expression is silently left untouched.
@@ -74,11 +74,9 @@ Value expressions can be used in conditional expressions by nesting them: `{if {
7474

7575
* Every expression in `{}` must resolve to a number.
7676
* Nested sub-expressions are evaluated before the current expression is evaluated.
77-
* Value Expressions and Conditional GCode are evaluated before any post-processing scripts.
77+
* Value Expressions and Conditional G-code are evaluated before any post-processing scripts.
7878

7979
# Troubleshooting
8080

8181
* If the parser can't understand your statements, it will output nothing for that block.
82-
* Remember that Custom GCode placeholders (items in `[]`) are resolved before Conditional GCode.
83-
84-
[^1]: http://www.partow.net/programming/exprtk/index.html
82+
* Remember that Custom G-code placeholders (items in `[]`) are resolved before Conditional G-code.

0 commit comments

Comments
 (0)