5axes / Calibration-Shapes

A Cura plugin that adds simple shapes (cube, cylinder, tube) and also 24 Calibration and test parts + 7 Postprocessing scripts
GNU Affero General Public License v3.0
340 stars 69 forks source link

RetractTower script doesn't change distance at first change layer when setting offset to 0 #94

Closed PurseChicken closed 2 years ago

PurseChicken commented 2 years ago

It seems that when using the RetractTower script, it doesn't start changing the retraction distance until the 2nd change layer.

For example, if you set the Distance to change at layer 60, it doesn't actually change until layer 120. Interestingly, it appears to start with the starting value entered into the script and then at the first change layer goes to 1 and then starts incrementing based on the increment value.

M117 also shows this. So if I have the script to start with a distance of 2 and increment 1 at layer 60 here is what happens: Layers 0-60 M117 distance (2.0/1.0) Layers 60-120 M117 retract E1.0 Layers 120-180 M117 retract E2.0 Layers 181-240 M117 retract E3.0 etc. Another example if you start with a distance of 1 and increment 1 at layer 60: Layers 0-60 M117 distance (1.0/1.0) Layers 60-120 M117 retract E1.0 Layers 120-180 M117 retract E2.0 Layers 181-240 M117 retract E3.0 etc. What's even stranger is if you flip the distance and increment values. So for example if you set distance starting value to 1 and increment by 2 at layer 60 results in: Layers 0-60 M117 distance (1.0/2.0) Layers 60-120 M117 retract E2.0 Layers 120-180 M117 retract E4.0 Layers 181-240 M117 retract E6.0 etc.

EDIT As I was typing this out I think I found the issue. It appears to do this weird behavior if you set the change layer offset to 0. If you set the change layer offset to a positive integer, then the script appears to work as expected. I would consider this a Bug in the script. Its almost like if "ChangeLayerOffset" is 0 then it assumes the offset is the change at layer.

PurseChicken commented 2 years ago

I was digging through RetractTower.py and I couldn't find where the problem was. Interestingly when the gcode was generated, I didnt see "M117 Start" anywhere which didnt make sense. I started troubleshooting by changing one of the M117 lines that write to gcode and my changes were not showing! I started thinking that maybe Cura caches the python files.

After the long haul, I found that Cura had a Scripts folder in my %APPDATA% directory that had older versions of a couple of scripts. Namely, RetractTower.py. I deleted these scripts as well as the contents of the _pycache_ subdirectory and this fixed the issue. It appears that these scripts were overwriting the newer ones from the latest install of Calibration Shapes.

The Specific path on Windows 10 is: C:\Users\<username>\AppData\Roaming\cura\\scripts %AppData%\Roaming\cura\\scripts E.G. C:\Users\pursechicken\AppData\Roaming\cura\4.13\scripts or %AppData%\Roaming\cura\4.13\scripts

Once those scripts were removed it seemed to then use the correct scripts in the plugins\CalibrationShapes directory.