<p>I am using Cura for slicing, and OctoPrint for the actual printing.</p>

<p>On small pieces with roughly one square cm of surface area prints over about 6&nbsp;mm have a risk of coming off at 60&nbsp;&deg;C.</p>

<p>In fact, I have had to use 71&nbsp;&deg;C so it stick properly.  However, I don't want the print bed that hot all the time.  I would like to try a different number of layers at different bed temperatures till I get it right.</p>

<p>Gradually, over the course of 1-3&nbsp;mm, for the bed temperature to decrease back to 60&nbsp;&deg;C to save on electricity.  Possibly even 50&nbsp;&deg;C as the layers get higher.</p>

<p>Cura only support the initial layer having a different temperature and that isn't enough.</p>

<p>Apparently you can have custom user events with <a href="https://docs.octoprint.org/en/latest/events/index.html" rel="nofollow noreferrer">OctoPrint</a>, one of them being <strong>ZChange</strong> which is great.</p>

<pre><code>{__currentZ}: the current Z position of the head if known, -1 if not available
</code></pre>

<p>I need on the ZChange event to check the <code>__currentZ</code> and execute an<code>M140</code> with a temperature varying with layer height.  Normally I would use a simple <code>if</code> command or etc., but how do I implement this here.</p>

<p>However, its seems you can execute a command or a G-code.</p>

<p>I can't seem to find any examples where I can test the Z height in layers or mm and execute a different temperature for different layers.</p>

<p>An additional problem is the increased temps cause the model to melt so that the opening is smaller nearest to the glass than most of the rest of the model.</p>

<p>I am height of the raft, which helps, but I am hoping for a compromise.  </p>

<p>The print bed shouldn't need to be 70&nbsp;&deg;C for the whole vertical height of the model.</p>

<p>Any suggestions?</p>

[{'answer_id': 11711, 'author': '0scar', 'author_id': 5740, 'author_profile': 'https://3dprinting.stackexchange.com/users/5740', 'pm_score': 2, 'selected': False, 'text': '<p><strong>The actual problem you are facing is bed adhesion</strong>, the proposed solution (in your question) shouldn\'t be the preferred solution to get your parts to stick to the plate/glass as plastic shrinks as it cools down. Note that a 5&nbsp;&deg;C temperature drop after the first layer usually isn\'t a problem, but larger temperature differences or shutting off the heat completely will cause your parts to come off the glass.</p>\n\n<p>Note that PLA requires a temperature of about 60&nbsp;&deg;C (for adhesion as this is close to the glass temperature where the plastic is soft; however, note that PLA can be printed on cold bed surfaces on suitable bed surfaces). The slate of glass is an insulator, so it is perfectly possible that you need to set the bed at a higher temperature to get 60&nbsp;&deg;C at the surface of the glass plate. When the lower layer deforms the bed temperature is too high.</p>\n\n<p>As you are using Cura, there is a plugin available called TweakAtZ, nowadays this is a default plugin. How to use this is described in <a href="/a/7346/">this anser</a> (on question <a href="/q/7345">"How does one use a heat tower?"</a>); instead of changing the hotend temperature you will need to modify the bed temperature instead (using <code>M140</code>).</p>\n\n<p><strong>To solve the actual problem</strong>, you need to prepare the glass by cleaning it properly, use a level bed with a correct initial nozzle to bed distance for <code>Z=0</code> (usually thickness of a plain paper sheet A4/Letter) and an adhesive like hairspray, glue stick or a dedicated adhesion spray like 3DLAC or Dimafix. I\'m using 3DLAC for several years (for PLA and PETG; Dimafix is supposed to be more sticky at higher temperatures, so for ABS for instance) and never had any problems with adhesion on properly levelled beds. See <a href="/a/4045">this answer</a> for another user\'s experience.</p>\n\n<p>An OctoPrint solution using event as you suggest is not recommended. This is the config.yaml, e.i. the configuration of the print server, not a print instance option file. Furthermore, there are yet no plugins that can handle additional code when the head reaches a certain (layer)height. This is pretty tricky if you use Z position detection when the head also can hop, such code should be inserted by the slicer instead.</p>\n\n<hr>\n\n<p><em>Related to your question are the answers on question: <a href="/q/10683">"Why keep the bed heated after initial layer(s) with PLA (or PETG)?"</a>.</em></p>\n'}, {'answer_id': 11733, 'author': 'user77232', 'author_id': 12857, 'author_profile': 'https://3dprinting.stackexchange.com/users/12857', 'pm_score': 0, 'selected': False, 'text': "<ul>\n<li>You can manually edit the file. Look for the line that has the Z height of your choice, and insert the temp change g-code right above it.</li>\n<li>Upgrade to a real slicer like Simplify3D with has an options to set a heater temp at different layers.</li>\n<li>Preheat the bed before you print, then print with a bed temp set lower than the temp you preheated at. This will give the illusion of a temp change.</li>\n</ul>\n\n<p><em>(I for one turn off my bed after the first layer, when I'm printing PLA. I also don't have proper cooling (at this time), my environment is humid (59.9%) and the ambient air temp is 31C.) - just for context</em></p>\n"}]
['https://3dprinting.stackexchange.com/questions/11710', 'https://3dprinting.stackexchange.com', 'https://3dprinting.stackexchange.com/users/16395/']