Jump to content

Is there a post processing Plugin for sentence Numbers?


Ov3rDr1ve
Go to solution Solved by Slashee_the_Cow,

Recommended Posts

Posted · Is there a post processing Plugin for sentence Numbers?

Good evening,

i am starting to build my own Delta-Bot Printer and also trying to programm it myself via Codesys.

 

As i understood correctly, the Funktion Blocks from codesys needs the sentence number in the gcode to read it.

For example :

 

N1 G1 X100 Y100 Z1

N2 G1 X150 Y100 Z1

N3... etc.

 

I havent found any options or plugins that will create also the sentence number in the gcode... 

Is there any plugin or option for that ? 

 

  • Link to post
    Share on other sites

    • Solution
    Posted (edited) · Is there a post processing Plugin for sentence Numbers?

    Try this, although it's pretty crude and modifies every line in the g-code which isn't a comment. Copy AddSentenceNumbers.py file inside the zip file I attached into the scripts folder in your Cura configuration folder (if you don't know where that is, in Cura, go to Help > Show Configuration Folder). Restart Cura.

     

    In the Cura menus go to Extensions > Post Processing > Modify G-Code. That should bring up a window with post processing scripts (you might not have any turned on). Click Add a script, and choose Add Sentence Numbers. Then just set the options to the right of that (Sentence Number Prefix - what needs to start the line - in your case just put N in that box) and if necessary change the starting number (surely someone has a printer which is zero-based).

     

    Oh, and please let me know how it goes. Seeing the results in g-code on my computer is one thing but knowing if something actually works in a real world situation is something else entirely.

     

    AddSentenceNumbers.zip

    Edited by Slashee_the_Cow
    Updated version of script attached
    • Like 2
    Link to post
    Share on other sites

    Posted (edited) · Is there a post processing Plugin for sentence Numbers?

    Thank you very much for your help 🙂

     

    It works for me aswell. The only thing i noticed is, that N1 starts at the comment Postprocessed...

     

    ;MINZ:0.3
    ;MAXX:73.3
    ;MAXY:71.299
    ;MAXZ:8
    N1 ;POSTPROCESSED
    ;Generated with Cura_SteamAngine 5.4.0
    N2 M140 S60
    N3 M105
    N4 M190 S60

     

    I am not sure if this will be a problem or not, but i guess if there is no real command in the sentence then the program will jump to the next sentence.

     

    But thank you very much 🙂

     

    PS: Is it also possible to delete all the comments ind the Code?

          Codesys sees the comments as error but still accepts the code. So that means that your Script is            working 🙂

    Edited by Ov3rDr1ve
  • Link to post
    Share on other sites

    Posted (edited) · Is there a post processing Plugin for sentence Numbers?

    I have a post that removes all the comments.  It's one of the 8 scripts included in "Little Utilities".  I guess UM2's don't like all the comments either.

    LittleUtilities.zip

     

    In regards to Slashee's "AddSentenceNumbers" she will likely take a look at it tomorrow.  Maybe add numbering the comments as an option, or you could run "Remove Comments" first and then do the numbering.

     

    The last section of any Cura gcode file is all comments and includes the setting differences between the stock profile and whatever you changed for the print.  That section isn't in the gcode during post processing so it can't be removed.  The same goes for the line " ;POSTPROCESSED" which is also added after post processing is complete.

    If either the last section " ;SETTING_3 " or the line " ;POSTPROCESSED" is an issue they would need to be manually deleted.

     

     

    Edited by GregValiant
    • Like 1
    • Heart 2
    Link to post
    Share on other sites

    Posted (edited) · Is there a post processing Plugin for sentence Numbers?

    Sorry, should have looked a bit closer at the resulting g-code on my end. The problem is that for that line (and the start of each layer) it doesn't actually give post processing scripts the line (so it can't see that it starts with a comment), just a blank line (easy enough to find and not alter).

     

    Hopefully this version should fix that problem.

    AddSentenceNumbers.zip

     

    Quote

    If either the last section " ;SETTING_3 " or the line " ;POSTPROCESSED" is an issue they would need to be manually deleted.

    I hate to prove people wrong (just kidding) but no they don't 🙂.

    Edited by Slashee_the_Cow
    Added quote one-upping Greg
  • Link to post
    Share on other sites

    Posted · Is there a post processing Plugin for sentence Numbers?

    Slight bugfix 'cause I can (you probably don't need to worry about this), and hopefully not one of those fixes which unfixes things. Just a bit of exercise to keep my programming muscles in shape.

     

    - If by some miracle of slicing the same command occurs twice in one layer (possibly slightly less of a miracle if you're using relative positioning, not absolute), there was a veeeeeeery slight chance that it would add the number to the wrong line. This has now been fixed.

    - Speed has been increased, probably by an order of magnitude. But given how long it doesn't take already, you'd need a massive gcode file to notice any possible difference.

    AddSentenceNumbers_v3.zip

    • Thanks 1
    Link to post
    Share on other sites

    Posted · Is there a post processing Plugin for sentence Numbers?

    So, did it work?

  • Link to post
    Share on other sites

    Posted · Is there a post processing Plugin for sentence Numbers?
    18 hours ago, ahoeben said:

    So, did it work?

    Totally not out of vanity and more based on the rule of "people are much quicker to criticise than praise" I'm going to guess yes.

  • Link to post
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
    • Our picks

      • UltiMaker Cura 5.8 beta released
        Another Cura release has arrived and in this 5.8 beta release, the focus is on improving Z seams, as well as completing support for the full Method series of printers by introducing a profile for the UltiMaker Method.
        • 1 reply
      • Introducing the UltiMaker Factor 4
        We are happy to announce the next evolution in the UltiMaker 3D printer lineup: the UltiMaker Factor 4 industrial-grade 3D printer, designed to take manufacturing to new levels of efficiency and reliability. Factor 4 is an end-to-end 3D printing solution for light industrial applications
          • Like
        • 3 replies
    ×
    ×
    • Create New...