domoszlai / juicy-gcode

A lightweight SVG to GCode converter for maximal curve fitting
https://hackage.haskell.org/package/juicy-gcode
MIT License
110 stars 7 forks source link

In some cases g-code generates with offset #12

Closed berkut0 closed 4 years ago

berkut0 commented 4 years ago

With rectangle g-code generates with no issues, but without it has strange offset. I will send svg to your email.

image

domoszlai commented 4 years ago

Please share the SVG

berkut0 commented 4 years ago

I sent it to your email

domoszlai commented 4 years ago

Ok, it was in the spam folder, I have it now

domoszlai commented 4 years ago

The two files are quite different actually. These are the first lines from both:

<polygon id="_x30_:1:0.7492647058823529_2_" points="399.5,305.2 399.5,305.2 399.5,305.2 "/>
<polygon id="_x30_:1:0.7492647058823529_2_" points="399.5,305.2 399.5,305.2 399.5,305.2 399.5,305.2 "/>

In one SVG the polygons have one more coordinate pair. I think the generated gcode is in par with this.

With the default settings:

G17
G90
G0 Z10
G0 X0 Y0
M3
G4 P2000.000000
G00 Z10
G00 X140.9347 Y102.3408
G01 Z0 F10.00
G01 X140.9347 Y102.3408
G01 X140.9347 Y102.3408
G01 X140.9347 Y102.3408
G00 Z10

and the other

G17
G90
G0 Z10
G0 X0 Y0
M3
G4 P2000.000000
G00 Z10
G00 X140.9347 Y102.3408
G01 Z0 F10.00
G01 X140.9347 Y102.3408
G01 X140.9347 Y102.3408
G01 X140.9347 Y102.3408
G01 X140.9347 Y102.3408
G00 Z10

this also looks good to me.

These are really strange polygons though :) I'm not sure that these gcodes are usuable

berkut0 commented 4 years ago

I don't know where additional coordinate pair came from Some of the repeating coordinates are the former circle. I do this before exporting to get the "point".

berkut0 commented 4 years ago

If you look at the screenshot above, you can see that there are still four coordinates, but there is an offset.

domoszlai commented 4 years ago

What do you mean by offset?

berkut0 commented 4 years ago

изображение изображение

it's the same file but only with one modification rectangle with size bigger than other graphics

domoszlai commented 4 years ago

in the gcode files you sent me, the coordinates are the same. and if I generate the gcode from the two SVGs, the coordinates are also the same (only there is one more line because of the extra coordinate pair). So, I can't really reproduce he discrapency you show me on the picture

berkut0 commented 4 years ago

It's strange, but I cant to reproduce it by myself now. This was a stable result on two files. Now I will try to repeat all the steps from the very beginning to achieve the same result.

I attach svg files for future experiments: render.zip, lenna.zip

berkut0 commented 4 years ago

And, there it is: issue.zip изображение

domoszlai commented 4 years ago

The SVGs are different. The first polygons are:

lenna_alpha_export.svg

<polygon id="_x30_:1:1.4141612200435727" points="266.7,275.5 266.7,275.5 266.7,275.5 266.7,275.5 "/>

lenna_alpha_rect_export.svg

<polygon id="_x30_:1:1.4141612200435727" points="390,275.5 390,275.5 390,275.5 390,275.5 "/>

That's why the gcode is different

berkut0 commented 4 years ago

Is it a bug in Adobe Illustrator svg exporter?

domoszlai commented 4 years ago

I can't say that. Looks like the whole image is shifted horizontally. It is either a bug in the exporter, or you make a mistake :)

berkut0 commented 4 years ago

Thank you! 🙏

domoszlai commented 4 years ago

👍