I need a plugin that adds spaces



  • When I get a g-code files from a fanuc machine. The machine deleted all the space. It is not easily readable anymore. So I need a plugin that ads the spaces again. (sending the files with spaces to the machine is no problem the machine removes them to conserve memory).

    a file from the machine would look like this:

    @018%
    O1000
    ( COMMENTS )
    M165
    M62

    T12M6( CENTERBOOR SECO )
    T37
    M98P1001( NULPUNT VOORKANT RND 13 )
    G00X0.Y0.S1800F300M3
    G00G43H12Z60.M8
    G82Z-3.R4.P400K0
    M98P1013
    M98P1002( NULPUNT VOORKANT M8 )
    G00X0.Y0.S1800F300M3
    G00G43H12Z60.M8
    G82Z-2.R4.P400K0
    M98P1008
    %

    The machine put everything together except the comments ( )
    Plugin needs to accept “blocks” a block is something like this: M98 or X123.43 or R4.
    Here the file but then how I need to to be converted to:
    @018%
    O1000
    ( COMMENTS )
    M165
    M62

    T12 M6 ( CENTERBOOR SECO )
    T37
    M98 P1001 ( NULPUNT VOORKANT RND 13 )
    G00 X0. Y0. S1800 F300 M3
    G00 G43 H12 Z60. M8
    G82 Z-3. R4. P400 K0
    M98 P1013
    M98 P1002 ( NULPUNT VOORKANT M8 )
    G00 X0. Y0. S1800 F300 M3
    G00 G43 H12 Z60. M8
    G82 Z-2. R4. P400 K0
    M98 P1008

    So can anybody help me with this?
    Thanks



  • What about using find/replace dialog with a regular expression like \w\d+ and replace with $0 (there is a space after zero digit)



  • @Fortuneskills

    better use \w\-*\d+\.* to have negative movement and coordinate dots glued to correct code.



  • Hello, @fortuneskills, @eko-palypse, and All,

    Presently, I’m not able to give you a full reply to your request but I should have more time on next Sunday ! I’ll also need some other samples of code, either before ( text you get ) and after ( Text you would like to ), to improve my regex S/R !

    Assuming your single example, here is my temporary solution :

    • SEARCH (?-si)(?:\(.+?\)|@\d+?%|^\w{3,5}|[PSFM]\d+|[\w-]{2,3}\.?)(?=\R)|(^\w{3}|[PSFM]\d+|[\w-]{2,3}\.?)

    • REPLACE $0(?1\x20)

    • Option Wrap around ticked

    • Option Regular expression selected

    • Click on the Replace All button

    See you later,

    Best Regards

    guy038


Log in to reply