Need help for CNC code.
-
Greetings to everyone! I’m a newbie here, hoping to get some answers to a few questions. I began CNC programming using Solid Works 2018, a program designed for writing CNC code with a generic post-processor. I want to share my problem with you.
(Generic text “GENERIC TEXT” GENERIC TEXT, )
(GENERIC TEXT, generic text. )
N1 G00 G90 G17 G40 G80 G71
N2 (12MM CRB 2FL 25 LOC)
N3 X25.4 Y25.4 T03 M06
N4 G75 S2000 M03
N5 G90 G54 G00 X13.539 Y10.764
N6 Z3.
N7 G01 Z-10. F400. M08
N8 G41 X17.951 Y6.351 F150.
N9 G03 X18.8 Y6. I18.8 J7.2
N10 G01 X20.
N11 X40. F100.
N12 G02 X46. Y0 I40. J0
N13 G01 Y-40.
N14 G02 X40. Y-46. I40. J-40.
N15 G01 X0
N16 G02 X-6. Y-40. I0 J-40.
N17 G01 Y0
N18 G02 X0 Y6. I0 J0
N19 G01 X20.
N20 X21.2
N21 G03 X22.049 Y6.351 I21.2 J7.2
N22 G40 G01 X26.461 Y10.764
N23 G00 Z3.
N24 Z25. M09
N25 M05
N26 M02This is the code that I got. I have to rewrite it like this in order for machine to work:
N0 %
N1 G00 G90 G40
N3 X25.4 Y25.4 T03 M06
N4 G75 S2000 M03
N5 G90 G00 X13.539 Y10.764
N6 Z3.
N7 G01 Z-10. F400 M08
N8 G40 X17.951 Y6.351 F150
N9 G03 X18.8 Y6. I18.8 J7.2
N10 G01 X20.
N11 X40. F100
N12 G02 X46. Y0 I40. J0
N13 G01 Y-40.
N14 G02 X40. Y-46. I40. J-40.
N15 G01 X0
N16 G02 X-6. Y-40. I0 J-40.
N17 G01 Y0
N18 G02 X0 Y6. I0 J0
N19 G01 X20.
N20 X21.2
N21 G03 X22.049 Y6.351 I21.2 J7.2
N22 G40 G01 X26.461 Y10.764
N23 G00 Z3.
N24 Z25. M09
N25 M05
N26 M02
N27 E
This is my problem.
I have a recurring issue with the beginning and end of my code. I always have to replace the generic text with ‘%’ and manually add an ‘E’ at the end of the program whenever I rewrite it. Is there a way to automate this process?
Whenever I get a new program, I have to correct F400. F200. (or any Fxxx. not to have a period at the end of Fxxx). Can I automate that as well? -
@Radomir-Stojanović - I believe this article applies FAQ: You’ve asked your question in the wrong place!
This forum is for supporting the Notepad++ text editor, and to a lesser extent, the regular expression system implemented by Notepadd++ plus some of the Notepad++ plugins.
-
I think this is the right place for this question.
It is about how to transform this text:
into this text:
Note that I’ve intentionally shown the two texts as a “diff”.
-
-
@Radomir-Stojanović said in Need help for CNC code.:
I have a recurring issue with the beginning and end of my code. I always have to replace the generic text with ‘%’ and manually add an ‘E’ at the end of the program whenever I rewrite it. Is there a way to automate this process?
Whenever I get a new program, I have to correct F400. F200. (or any Fxxx. not to have a period at the end of Fxxx). Can I automate that as well?This can easily be done with 3 regular expressions (regex), however the 3rd one won’t be completely sorted, I will speak to that later.
So using the Replace function we have the first one which deals with the “generic text issue”.
Search mode must be regular expression for all 3 regex I’m showing.
Find What:(?-s)\A(\([^)]+\)(\R))+
Replace With:N0 %${2}
Click on Replace AllNow we deal with all the Fxxx. sequences.
Find What:(F\d+)\.
Replace With:${1}
Again click on Replace AllFinally the end line for the code. The primary problem here is that regex cannot count. So there isn’t an easy way for the regex to add 1 to the last line and write a new line with the incremented number and and E. So what my regex does is to write it with xx as the line number. So you would still need to change the xx for the real line number. Although I have provided this regex, I think it would be of limited value as you would still need to edit that last line.
Find What:(?-s)(\R).+\K\z
Replace With:${1}Nxx E
These 2 (or 3) regex can be combined into a macro which is essentially the keystrokes recorded as you type them and once saved (with a name) can be re-run whenever you wish.
Terry
-
This post is deleted!