from mecode import G
import random
import numpy as np
gridsize=[20,20]
gridlength=15
repeat=4
# new function to draw a line
def drawline(x,y):
# find top right corner
gridlengthmult=.8#random.randint(1,2)
topleftcorner=[x*gridlength,y*gridlength]
# move to top left corner
print(";topleftcorner"+str(topleftcorner))
# choose random corner
lrtb=[random.randint(0,1),random.randint(0,1)]#left right top bottom choose random corner
# find startpoint in global coordinates
startpoint=[topleftcorner[0]+lrtb[0]*gridlength*gridlengthmult,topleftcorner[1]+lrtb[1]*gridlength*gridlengthmult]
print(";startpoint"+str(startpoint))
# find endpoint in global coordinates
endpoint=[topleftcorner[0]+(1-lrtb[0])*gridlength*gridlengthmult,topleftcorner[1]+(1-lrtb[1])*gridlength*gridlengthmult]
print(";endpoint"+str(endpoint))
# do arcmovement
x_dim=endpoint[0]-startpoint[0]
y_dim=endpoint[1]-startpoint[1]
print(";x_dim"+str(x_dim))
print(";y_dim"+str(y_dim))
g.move(startpoint[0],startpoint[1])
g.move(z=0)
g.relative()
g.arc(x=x_dim,y=y_dim,radius=gridlength*gridlengthmult)
g.absolute()
g.move(z=10)
#g = G()
g= G("hello.gcode",header="header.gcode",footer="footer.gcode")
g.absolute()
g.abs_move(z=10)
# loop through grid
for x in range(gridsize[0]):
for y in range(gridsize[1]):
for z in range(repeat):
drawline(x,y)
and the output is always missing a few characters on line 4306. weirdly enough.
This doesnt happen when i output to the console. It seems that sometimes the output after 4306 is even from the last time the code ran.
hey im generating gcode like this within a jupyter notebook:
and the output is always missing a few characters on line 4306. weirdly enough.
This doesnt happen when i output to the console. It seems that sometimes the output after 4306 is even from the last time the code ran.