Improve preprocessor capabilities

Issue #345 resolved
Daniel Friderich created an issue

I like FlatCAM so far, but to create working G-Code for Isel CNC mills, it lacks some features in the preprocessor.

Allow generated G-Code without any G20 or G21 codes.

FlatCAM shouldn’t fail to generate, show or save a G-Code file without the above codes. The Isel ICP CNC mill doesn’t use the codes. It uses a custom statement as first line of the G-Code file to set the mill to mm. FlatCAM 8.99 (current Beta) fails to generate G-Code in line 6682 in function export_gcode(self, filename=None, preamble='', postamble='', to_file=False)of FlatCAMObj.py.

A boolean flag in preprocessor file to disable the FlatCAM header addition to the G-Code file.

I.e. don’t add self.gcode_header() in function export_gcode(self, filename=None, preamble='', postamble='', to_file=False) in FlatCAMObj.pyto the G-Code file. Imho export_gcode(..) should check if a boolean flag was set in preprocessor and shouldn’t depend on hardcoded preprocessor names like it is now (Roland_MDX_20 & hpgl).

The reason for this is that ISEL ICP CNC mills depend on IMF_PBL projectName being the first line of the G-Code file.

Allow for Windows style line endings (\r\n) in G-Code not generated in preprocessor.

As far as I can see, the only place this is happening is line 2268 of camlib.py. Again Isel ICP mills expect Windows style line endings (\r\n) and will fails to pares the G-Code file if otherwise.

I have attached the preprocessor file, that generates working G-Code for Isel ICP mills, if the above issues are fixed by some crude hacks to FlatCAM 8.99 (current Beta).

Comments (8)

  1. Marius Stanciu

    Hi Daniel,

    I don’t know if there is still time to include this in the current build. I was about to release the 8.99 build … What you see in the Beta branch until a release is made (files are published in the Downloads section) are just updates working up to 8.99. I know it is confusing but due of the current situation this is what it is.

    I will try to fix this but if this require more work on FlatCAM, like changing how things are done and if needs to be propagated to other preprocessors it will remain for the next release. Right now I’m on the run so I don’t have the time to look (and read carefully) your proposal but I will check it asap.

    Best,
    Marius

  2. Marius Stanciu

    Ok Daniel, try the latest commit and see if it works for you. I don’t have time to check it but try it and report issues (if any) here.

  3. Daniel Friderich reporter

    Generating G-Code for from Gerbers for isolation routing works with your patch.

    It still has no Windows style line endings (\r\n) when using FlatCAM on macOS, but that's easy enough to fix with an external editor.

    Generating G-Code for drilling holes from an Excellon file fails when trying to view or save the CNC Job object in FlatCAM Beta 8.99.

    [success] Opened: /Users/Path/KiCAD/ExcellonFile.drl
    Creating a list of points to drill...
    Starting G-Code...
    Starting G-Code for tool with diameter: 1.5MM.
    Starting G-Code for tool with diameter: 2.2MM.
    Finished G-Code generation...
    Parsing GCode file. Number of lines: 58
    Creating Geometry from the parsed GCode file. ...
    Unifying Geometry from parsed Geometry segments: 0
    [ERROR_NOTCL] G-code does not have a units code: either G20 or G21
    [ERROR] FlatCAMCNNJob.on_edit_code_click() --> 'NoneType' object has no attribute 'getvalue'
    

  4. Marius Stanciu

    You are not using the latest commit.

    The message: “G-code does not have a units code: either G20 or G21“ is no longer active in FlatCAM.
    Regarding the windows line endings you need to make the setting in Edit → Preferences → CNC-Job → CNCJob General → Force Windows-style line endings.

    Please report if those changed are fixing your issues.

  5. Daniel Friderich reporter

    You are right, I wasn’t using the latest commit. My apologies for that.

    Thank you for showing me the ‘Force Windows style line-ending’ option. I wasn’t aware it existed. The above issues are fixed. Thank you for your time and effort.

    I guess the Start Z functionality is not yet fully implemented? The only place I can see to set it is in the Tool Database.

    All issues in this ticket are fixed. Thank you again for your fast response.

  6. Daniel Friderich reporter

    I removed my badly hacked Windows line-endings (\r) from the preprocessor file. I can't create a pull request for it for some reason.

  7. Marius Stanciu

    Hello Daniel,

    The Start Z is not a setting that is used much so basically it’s something that you set either in Tools Database like you saw but mainly in Edit → Preferences, in the Excellon and Geometry tabs. Once set, they are used all over.

    I will update the preprocessor with the data in the file you just atatched.
    Actually I was thinking in letting people build their own preprocessors in a FlatCAM tool. But that’s for the future.

    Best,
    Marius

  8. Log in to comment