Temp Tower Setup Troubles -- Slic3r (How do you format G-Code {if} statements?) I watched with great interest this video: Temp Tower - Slic3r Gcode Placeholders - How To - Chris's Basement -- Jan 23, 2019    Chris Riley  

I found a model I'm happy with: Smart compact temperature calibration tower by gaaZolee, December 24, 2017 Uses Layer 0.20&nbsp;mm  infill: 15&nbsp;%  

I'm testing a stubborn new spool of PLA.  Temp range of test 225&nbsp;&deg;C to 180&nbsp;&deg;C.  That model above came with recommended ifstatements.  I verified that with 100&nbsp;% thickness on first layer, I'm exactly hitting all the Z targets at exactly the correct place for each temperature story on the tower.  

I'm using the Slic3r "Printer Settings" tab - to place my if statements in place at "Before Layer Change G-Code".  

It's not clear to me on the format required for a G-Code {if} statement.  I've tried... 

{if layer_z == 7.8}M104 S225{endif};   // fail, this converts to: M104 S225 {endif}    
{if layer_z==1.6}M104 S225             // fail, this converts to: M104 S225    
{if [layer_z]==1.6} M104 S225          // fails, this converts to: (null)    
{if [layer_num]==8} M104 S225          // fails, this converts to: (null)    
{if layer_num==8} M104 S225          // fails, this converts to: M104 S225 


In detail what I'm seeing is the if statements from all ten towers prints as change temp to 225, 220, 215, 210... down to 180 (last entry) and 180&nbsp;&deg;C is where ALL my prints get printed at.  Total Fail. 

I'm just not seeing anything in the Gcode output from Slic3r that remotely looks like an if statement.  Any ideas here?  I've seen this reference, on advanced conditional G-Code but I'm just not understanding what to do here.  

I do see from Slic3r Custom G-Code Placeholder Reference, that I'm using the correct terms.   [layer_z] - Z height of the active layer, and [layer_num] - Integer number of the active layer. It's not clear if their use in "Before Layer Change G-Code" require the square brackets or not.  

Any clues on how to get an if statement into G-Code via Slic3r for a temperature tower print?
So I think I figured this one out.  I was looking at it a bit wrong.  And here's my code:
; Note to self:  layer_z = [layer_z]
; T tower floor 1
{if [layer_z]==1.6} M104 S225 T0
; T tower floor 2
{if [layer_z]==11.6} M104 S220 T0
; T tower floor 3
{if [layer_z]==21.6} M104 S215 T0
; T tower floor 4
{if [layer_z]==31.6} M104 S210 T0
; T tower floor 5
{if [layer_z]==41.6} M104 S205 T0
; T tower floor 6
{if [layer_z]==51.6} M104 S200 T0
; T tower floor 7
{if [layer_z]==61.6} M104 S195 T0
; T tower floor 8
{if [layer_z]==71.6} M104 S190 T0
; T tower floor 9
{if [layer_z]==81.6} M104 S185 T0
; T tower floor 10
{if [layer_z]==91.6} M104 S180 T0

The key to understanding what is going on is the ; Note to self:  layer_z = [layer_z] line.  The whole block of code above gets repeated for every layer of the print in the G-code, but it gets evaluated.  And when I search for &quot;layer z =&quot; and scan thru the code.. I eventually see this...
; Note to self:  layer_z = 1.6
; T tower floor 1
 M104 S225 T0                  &lt;---- Yowza. Nice. 
; T tower floor 2
; T tower floor 3
; T tower floor 4
; T tower floor 5
; T tower floor 6
; T tower floor 7
; T tower floor 8
; T tower floor 9
; T tower floor 10

and then again:
; Note to self:  layer_z = 11.6
; T tower floor 1
; T tower floor 2
 M104 S220 T0           &lt;---- Yes!
; T tower floor 3
...

All good. You have to have {} and [] within the code statements...
Addendum:  So it turns out things are not quite perfect.  I'm noticing at the upper floors, where things should be cooler, the temperature isn't changing.  Its locked at 215C.  I see this in the code:
; Note to self:  layer_z = 31.5999999999999      &lt;--- not sure how that happened.  
; T tower floor 1
; T tower floor 2
; T tower floor 3
; T tower floor 4
; T tower floor 5
; T tower floor 6
; T tower floor 7
; T tower floor 8
; T tower floor 9
; T tower floor 10

31.6 would have triggered a temperature change.  31.5999999999999 won't do it. I need to modify the {if... == } to a complex test between two values...   Just wanted to share that observation here.
I do see from this reference that

Expressions may be chained for an implicit AND:
{if [layer_num] == 10}{if [temperature_1] != 210}M104 S210

And this seems to fix it:
; Note to self:  layer_z = [layer_z]
; T tower floor 1
{if [layer_z]&lt;=1.65}{if [layer_z]&gt;1.55} M104 S225 T0
; T tower floor 2
{if [layer_z]&lt;=11.65}{if [layer_z]&gt;11.55} M104 S220 T0
; T tower floor 3
{if [layer_z]&lt;=21.65}{if [layer_z]&gt;21.55} M104 S215 T0
; T tower floor 4
{if [layer_z]&lt;=31.65}{if [layer_z]&gt;31.55} M104 S210 T0
; T tower floor 5
{if [layer_z]&lt;=41.65}{if [layer_z]&gt;41.55} M104 S205 T0
; T tower floor 6
{if [layer_z]&lt;=51.65}{if [layer_z]&gt;51.55} M104 S200 T0
; T tower floor 7
{if [layer_z]&lt;=61.65}{if [layer_z]&gt;61.55} M104 S195 T0
; T tower floor 8
{if [layer_z]&lt;=71.65}{if [layer_z]&gt;71.55} M104 S190 T0
; T tower floor 9
{if [layer_z]&lt;=81.65}{if [layer_z]&gt;81.55} M104 S185 T0
; T tower floor 10
{if [layer_z]&lt;=91.65}{if [layer_z]&gt;91.55} M104 S180 T0