Skip to content

Commit

Permalink
Fixed another bug in speed towers
Browse files Browse the repository at this point in the history
  • Loading branch information
kartchnb committed Oct 27, 2022
1 parent 002ff51 commit 4cfbe31
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions AutoTowersGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ def __init__(self):

# Finish initializing the plugin after Cura is fully ready
CuraApplication.getInstance().pluginsLoaded.connect(self._onPluginsLoadedCallback)

# Make sure the plugin gets a chance to clean up after itself before Cura exits
CuraApplication.getInstance().getOnExitCallbackManager().addCallback(self._onExitCallback)


Expand Down
9 changes: 7 additions & 2 deletions Postprocessing/TravelSpeedTower_PostProcessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,20 @@ def execute(gcode, startValue, valueChange, sectionLayers, baseLayers, reference
# Determine the old speed setting in the gcode
oldSpeedResult = re.search(r'F(\d+)', line.split(';')[0])
if oldSpeedResult:
oldSpeed = float(oldSpeedResult.group(1))
oldSpeedString = oldSpeedResult.group(1)
oldSpeed = float(oldSpeedString)

# Determine the new speed to set (converting mm/s to mm/m)
# This is done based on the reference speed, or the
# "print speed" value when the gcode was generated
newSpeed = (currentValue * 60) * oldSpeed / (referenceSpeed * 60)

# Change the speed in the gcode
new_line = line.replace(f'F{oldSpeedResult.group(1)}', f'F{newSpeed:.1f}') + f' ; AutoTowersGenerator changing speed from {(oldSpeed/60):.1f}mm/s to {(newSpeed/60):.1f}mm/s'
if f'{oldSpeed:.1f}' != f'{newSpeed:.1f}':
# Change the speed for this line
new_line = line.replace(f'F{oldSpeedString}', f'F{newSpeed:.1f}') + f' ; AutoTowersGenerator changing speed from {(oldSpeed/60):.1f}mm/s ({oldSpeed:.1f}mm/m) to {(newSpeed/60):.1f}mm/s ({newSpeed:.1f}mm/m)'
else:
new_line = line + f' ; AutoTowersGenerator speed is already at desired {(oldSpeed/60):.1f}mm/s ({oldSpeed:.1f}mm/m)'

lines[lineIndex] = new_line

Expand Down

0 comments on commit 4cfbe31

Please sign in to comment.