Skip to content

Instantly share code, notes, and snippets.

@Valinwolf
Last active January 14, 2020 20:52
Show Gist options
  • Save Valinwolf/4170ba47b132f8389307bbf05104d1aa to your computer and use it in GitHub Desktop.
Save Valinwolf/4170ba47b132f8389307bbf05104d1aa to your computer and use it in GitHub Desktop.
A collection of tools for use with OctoPrint printers. (Mesh tools for UBL)

Installation

To install run the following commands:

sudo wget https://gist.githubusercontent.com/Valinwolf/4170ba47b132f8389307bbf05104d1aa/raw/tram -O /usr/local/bin/tram
sudo wget https://gist.githubusercontent.com/Valinwolf/4170ba47b132f8389307bbf05104d1aa/raw/remesh -O /usr/local/bin/remesh
sudo wget https://gist.githubusercontent.com/Valinwolf/4170ba47b132f8389307bbf05104d1aa/raw/adjust-mesh -O /usr/local/bin/adjust-mesh
sudo wget https://gist.githubusercontent.com/Valinwolf/4170ba47b132f8389307bbf05104d1aa/raw/preheat -O /usr/local/bin/preheat
sudo wget https://gist.githubusercontent.com/Valinwolf/4170ba47b132f8389307bbf05104d1aa/raw/octoprint-api.ini -O /etc/octoprint-api.ini
sudo chmod 755 /usr/local/bin/{tram,remesh,adjust-mesh,preheat}

After installation open /etc/octoprint-api.ini in your favorite editor, with sudo of course, and edit the settings to your liking.

Doing a full "reset"

The the commands in the following order. After each command, wait for the auto-home to complete.

tram
remesh
adjust-mesh
#!/usr/bin/python3
import configparser
from octorest import OctoRest
config = configparser.ConfigParser()
config.read('/etc/octoprint-api.ini')
cli = OctoRest(url=config['Server']['URL'], apikey=config['Server']['APIKey'])
print("Setting Position... Do NOT make adjustments until head stops moving.")
cli.gcode(["G29 A","G0 Z15","G0 X150","G0 Y150"])
adj = True
zpos = 15
while adj:
amt = float(input("Adjustment: "))
if amt == 0:
adj = False
elif zpos + amt >= -2:
zpos += amt
cli.gcode("G0 Z"+str(zpos))
else:
zpos = 0
cli.gcode(["G29 P6 C"+str(zpos + amt),"G0 Z0"])
cli.gcode("G29 P6 C"+str(zpos))
print("Saving Mesh and Returning Home...")
cli.gcode(["G29 S0","M500","M501","G28","G29 A"])
[Server]
URL=http://127.0.0.1:5000
APIKey=YOUR_KEY_GOES_HERE
[Temp]
Tool=200
Bed=40
#!/usr/bin/python3
import configparser
from octorest import OctoRest
config = configparser.ConfigParser()
config.read('/etc/octoprint-api.ini')
cli = OctoRest(url=config['Server']['URL'], apikey=config['Server']['APIKey'])
cli.gcode(["M104 S"+config['Temp']['Tool'],"M140 S"+config['Temp']['Bed']])
print("Preheat Commands Sent.")
#!/usr/bin/python3
import configparser
from octorest import OctoRest
config = configparser.ConfigParser()
config.read('/etc/octoprint-api.ini')
cli = OctoRest(url=config['Server']['URL'], apikey=config['Server']['APIKey'])
cli.gcode(["G29 P1","G29 P3","G29 A","G28","G29 S0","M500","M501","G28","G29 A"])
print("UBL Remesh Commands Sent.")
#!/usr/bin/python3
import configparser
from octorest import OctoRest
config = configparser.ConfigParser()
config.read('/etc/octoprint-api.ini')
cli = OctoRest(url=config['Server']['URL'], apikey=config['Server']['APIKey'])
cli.gcode(["G28","G0 Z150","G0 X150","G0 Y150","M84"])
print("Tram Commands Sent.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment