nick-parker / Bread

An experimental slicer for FFF 3D Printers
GNU General Public License v3.0
66 stars 10 forks source link

java uses localization for numbers which results in malformed gcode #7

Closed Patola closed 8 years ago

Patola commented 8 years ago

I use a computer in Brazil and here the numeric standard for decimals is comma, not point - e.g. 0,2mm instead of 0.2mm. It seems that java automatically uses this standard and the gcode results like this:

(...) ;travel G1 F1200 G1 X110 Y84,365 Z0,225 E-1,2 E-1,2 ;shell G1 X108,234 Y84,365 Z0,225 E-1,07997 E-1,07997 G1 X108,234 Y84,365 Z0,225 E-1,07994 E-1,07994 G1 X108,182 Y84,365 Z0,225 E-1,0764 E-1,0764 G1 X106,412 Y84,365 Z0,225 E-0,95611 E-0,95611 G1 X106,411 Y84,365 Z0,225 E-0,95609 E-0,95609 (...)

Which obviously does not work. If I start Bread with LC_ALL as "C", it works:

$ LC_ALL=C java -jar Bread.jar Prints/wave.stl Prints/wavesurface.stl config.txt teste.gcode (...) ;travel G1 F1200 G1 X84.362 Y90.002 Z0.225 E-1.2 E-1.2 ;shell G1 X84.362 Y110 Z0.225 E0.15921 E0.15921 G1 X84.638 Y111.742 Z0.225 E0.27909 E0.27909 G1 X85.439 Y113.314 Z0.225 E0.39897 E0.39897 G1 X86.686 Y114.561 Z0.225 E0.51885 E0.51885 G1 X88.258 Y115.362 Z0.225 E0.63873 E0.63873 (...)

Patola commented 8 years ago

No feedback on this issue and it seems so easy to solve! I would submit a patch, but I imported the project on eclipse and I cannot compile it, lots of error like 'for each' syntax stuff which seem to be related to the java version.

However, to fix it, one would edit main/Constants.java and change to (...)

public class Constants {
    static private java.text.DecimalFormatSymbols enus = new DecimalFormatSymbols(Locale.ENGLISH);
    static public final Point3D farPoint = new Point3D(0,0,1e9);

(...)

then change the two decimalformats to using these symbols

    static public DecimalFormat ext = new DecimalFormat("#.#####", enus);   //Extrusion
    static public DecimalFormat xyz = new DecimalFormat("#.###", enus); //Position

that would probably fix the problem but as I cannot compile, I cannot test it.

chasecaleb commented 8 years ago

Change your Eclipse project settings to use a newer JDK version and you'll be able to compile. Enhanced for loops were 1.6 or 1.7, but you might as well just use 1.8. Caleb Chase (253) 221-1445 On May 18, 2016 1:18 PM, Patola notifications@github.com wrote:No feedback on this issue and it seems so easy to solve! I would submit a patch, but I imported the project on eclipse and I cannot compile it, lots of error like 'for each' syntax stuff which seem to be related to the java version.

However, to fix it, one would edit main/Constants.java and change to (...) public class Constants { static private java.text.DecimalFormatSymbols enus = new DecimalFormatSymbols(Locale.ENGLISH); static public final Point3D farPoint = new Point3D(0,0,1e9); (...)

then change the two decimalformats to using these symbols static public DecimalFormat ext = new DecimalFormat("#.#####", enus); //Extrusion static public DecimalFormat xyz = new DecimalFormat("#.###", enus); //Position

that would probably fix the problem but as I cannot compile, I cannot test it.

—You are receiving this because you are subscribed to this thread.Reply to this email directly or view it on GitHub

nick-parker commented 8 years ago

Resolved with the code you provided @Patola - Sorry it took a few days, I've been crushed between some academic stuff and my Hyperloop project.

@chasecaleb thanks for jumping in - I also just added the requirement for JDK 1.8 to the readme. I use a Predicate in Infill.java, so earlier versions don't work.