Created
December 8, 2021 16:18
-
-
Save Hello1024/d2d71f0d7d1acc48d266a87db01d7505 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env python | |
from pygcode import * | |
import pygcode | |
import math | |
prefix = """ | |
M82 ;absolute extrusion mode | |
M140 S60 ; set bed temperature to 55 C and continue | |
M104 S200 ; set hot end temperature to 210 C and continue | |
M190 S60 ; wait for bed temperature to reach 55 C | |
M109 S200 ; wait for hot end temperature to reach 210 CG21 ;metric values | |
G90 ;absolute positioning | |
M82 ;set extruder to absolute mode | |
M107 ;start with the fan off | |
G28 X0 Y0 ;move X/Y to min endstops | |
G28 Z0 ;move Z to min endstops | |
G1 Z35.0 F1800 ;move the platform down 15mm | |
G92 E0 ;zero the extruded length | |
G1 F400 X50 E6 ;extrude 6mm of feed stock while moving in x | |
G92 E0 ;zero the extruded length again | |
G1 F1800 | |
G92 E0 | |
G10 | |
M107 | |
G0 F1800 X100 Y100 Z0.2 | |
G11 | |
""" | |
suffix = """ | |
M104 S0 ;extruder heater off | |
M140 S0 ;heated bed heater off (if you have it) | |
G91 ;relative positioning | |
G1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure | |
G1 Z+0.5 E-5 X-20 Y-20 F30 ;move Z up a bit and retract filament even more | |
G28 X0 Y0 ;move X/Y to min endstops, so the head is out of the way | |
M84 ;steppers off | |
G90 ;absolute positioning | |
M82 ;absolute extrusion mode | |
""" | |
for cls in pygcode.gcodes._subclasses(pygcode.GCodeMotion): | |
cls.param_letters.add('E') | |
line_width=0.60 | |
first_layer_height=0.2 | |
layer_height=0.06 | |
radius = 25 | |
height = 10 | |
E=0 | |
Z=0 | |
layer=0 | |
print(prefix) | |
print("G1 F900") | |
while True: | |
local_layer_height = layer_height | |
# Uncomment to make a cone. | |
#radius=radius-layer_height*2 | |
if radius<line_width or layer*layer_height>height: | |
break | |
# outline - goes around 2x | |
for angle in [x / 200.0 for x in range(0, 400)]: | |
local_radius = radius-abs(1-angle) * line_width | |
move_distance = 2*math.pi*local_radius/200 | |
if layer==0: | |
local_layer_height = first_layer_height+(angle/2.0)*layer_height | |
Z = (layer+angle/2.0)*layer_height+first_layer_height | |
E += move_distance*local_layer_height*line_width / (math.pi*(1.75/2)**2) | |
print("%s" % GCodeLinearMove(X=100+math.sin(angle*2*math.pi)*local_radius,Y=100+math.cos(angle*2*math.pi)*local_radius,Z=Z, E=E)) | |
# example infill | |
for angle in [x / 4.0 for x in range(1, 5)]: | |
local_radius = radius-line_width | |
move_distance = 2*math.pi*local_radius/4 | |
E += move_distance*local_layer_height*line_width / (math.pi*(1.75/2)**2) | |
print("%s" % GCodeLinearMove(X=100+math.sin(angle*2*math.pi)*local_radius,Y=100+math.cos(angle*2*math.pi)*local_radius,Z=Z, E=E)) | |
print("M106 S255") # Fan on | |
line_width=0.30 | |
layer += 1 | |
print("G1 F1800") | |
print(suffix) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment