2

When using some CAM software, the CNC code is usually generated properly with spaces. But for example when moved to "Citizen Cincom L20" machine via USB or network and edited there it lose spaces and also lose semicolons while preserving new lines which does work as semicolons anyway.

But since editing of CNC program happens in 3 places: CAM Software(ESPRIT in this case), CNC machine controller and also via text editor on the computer as postprocessor in ESPRIT is garbage.I've come up with this regex


([0-9]{1,2})([A-Z])

\1 \2

so


G1G99X5.4Z-.5F.12

Becomes


G1 G99 X5.4 Z-.5 F.12

that works in Kate to space everything back again for clearer reviwing of code. The only issue about it is that I need to do that manually for every file and I would like to automate it, preferably via Kate, so it would happen upon opening any ????.PRG plain text files.

But I do not exactly know how such happening should be called is it like macro or what ? I'm looking for some suggestions to accomplish this. Or maybe some alternative solutions

PovilasCNC
  • 23
  • 5

1 Answers1

1

First, go to View -> Tool Views -> Show Search and Replace. You will see

enter image description here

Make sure you:

  • Enable {} regex option on the right as you are using a regex
  • Enable "AB" option on the right that enables case sensitive matching
  • Select In Folder value from the dropdown on the right
  • Fill out the regex, replacement, Folder and the Filter fields with the appropriate values
  • Click Search button.

You will see the results in a separate pane and Replace / Replace Checked buttons will become enabled.

Review the replacements and click Replace Checked:

enter image description here

Then you may check the updated file contents, and if you are satisifed with the results, use Save All, also by pressing CTRL+L.

Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563
  • Well, that's an interesting way to solve this, very suitable for me. But I have coworkers who wouldn't manage to do this much and would waste time reading unspaced code. Not gonna mark this as an answer yet, just in case someone might suggest alternative method. Thank you. – PovilasCNC Nov 16 '21 at 10:41
  • @PovilasCNC No one needs to read any "unspaced code". Just as any other text editor that allows bulk file edit use the S&R feature as usual: fill out the fields with input data and hit replace all occurrences. No need to review the changes. – Wiktor Stribiżew Nov 16 '21 at 10:44
  • Yes, this would work fine for archived programs, but in the process of developing an algorithm is roughly this: 1: NC code is generated by ESPRIT (which is spaced at this point) 2: NC code gets transfered to machine (it gets unspaced there, but it's internal editor via its control visually adds spaces) 3: When program gets moved from machine to PC for partial alterations, this here is when someone else than me would usually say, its where its mostly needed. 4: steps are kinda repeated till its polished. A way to make an editor itself to do such spacing on open is needed. – PovilasCNC Nov 16 '21 at 12:42
  • @PovilasCNC Why use a text editor then? Write a Python/Powershell/Bash/etc. script. – Wiktor Stribiżew Nov 16 '21 at 12:43
  • yeah, that's another thing on my mind, making a post-postprocessor, that compensates for what is missing or impossible to adjust in that binary postprocessor, but that's for future as I would have to advance some skills to actually achieve that. – PovilasCNC Nov 16 '21 at 13:44