Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

output to textfile not working only until line 4306 #77

Open
daricht opened this issue Nov 19, 2022 · 2 comments
Open

output to textfile not working only until line 4306 #77

daricht opened this issue Nov 19, 2022 · 2 comments

Comments

@daricht
Copy link

daricht commented Nov 19, 2022

hey im generating gcode like this within a jupyter notebook:

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.

@toonijn
Copy link

toonijn commented Aug 16, 2023

It may be a little late, but...
The footer only gets written once you call

g.teardown()

@daricht
Copy link
Author

daricht commented Sep 27, 2023

Thanks for your response but i was not misssing the footer just inside the gcode file a few chars were missing and then it continued fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants