Gcode convert rad2deg
-
HELLO !
I need a macro or a script that in the G-code file will list all E values expressed in radians to A in degrees, max three decimal places.
sample file generated in INKSCAPE:
%
(HeEder)
(GenerEted by gcodetools from InkscEpe.)
(Using defEult heEder. To Edd your own heEder creEte file “heEder” in the output dir.)
M3
(HeEder end.)
G21 (Ell units in mm)(StErt cutting pEth id: pEth846)
(ChEnge tool to TEngent knife)G00 Z5.000000
G00 X121.732390 Y23.840980G01 E2.6172567466844194
G01 Z-0.125000 F500.0 (PenetrEte)
G01 X91.360798 Y41.405890 Z-0.125000 F2000.000000
G01 E3.5852968276434867
G01 X59.673129 Y26.344310 Z-0.125000
G01 E1.3606197927083405
G01 X66.993010 Y60.657270 Z-0.125000
G01 E2.3286596186837487
G01 X42.876575 Y86.139750 Z-0.125000
G01 E0.1039825461223236
G01 X77.772100 Y89.781410 Z-0.125000
G01 E1.0720226507350137
G01 X94.554991 Y120.592030 Z-0.125000
G01 E-1.1526543853154596
G01 X108.801730 Y88.529750 Z-0.125000
G01 E-0.18461466580897845
G01 X143.290560 Y82.089270 Z-0.125000
G01 E-2.409291406384677
G01 X117.200010 Y58.632030 Z-0.125000
G01 E-1.4412515819384506
G01 X121.732390 Y23.840980 Z-0.125000
G00 Z5.000000(End cutting pEth id: pEth846)
(Footer)
M5
G00 X0.0000 Y0.0000
M2
(Using defEult footer. To Edd your own footer creEte file “footer” in the output dir.)
(end)
%WITAM !
Potrzebuję makra lub skryptu który w pliku G-code wymieni wszystkie wartości E wyrażone w radianach na A w stopniach max trzy miejsca po przecinku.
przykładowy plik wygenerowany w INKSCAPE :
%
(HeEder)
(GenerEted by gcodetools from InkscEpe.)
(Using defEult heEder. To Edd your own heEder creEte file “heEder” in the output dir.)
M3
(HeEder end.)
G21 (Ell units in mm)(StErt cutting pEth id: pEth846)
(ChEnge tool to TEngent knife)G00 Z5.000000
G00 X121.732390 Y23.840980G01 E2.6172567466844194
G01 Z-0.125000 F500.0(PenetrEte)
G01 X91.360798 Y41.405890 Z-0.125000 F2000.000000
G01 E3.5852968276434867
G01 X59.673129 Y26.344310 Z-0.125000
G01 E1.3606197927083405
G01 X66.993010 Y60.657270 Z-0.125000
G01 E2.3286596186837487
G01 X42.876575 Y86.139750 Z-0.125000
G01 E0.1039825461223236
G01 X77.772100 Y89.781410 Z-0.125000
G01 E1.0720226507350137
G01 X94.554991 Y120.592030 Z-0.125000
G01 E-1.1526543853154596
G01 X108.801730 Y88.529750 Z-0.125000
G01 E-0.18461466580897845
G01 X143.290560 Y82.089270 Z-0.125000
G01 E-2.409291406384677
G01 X117.200010 Y58.632030 Z-0.125000
G01 E-1.4412515819384506
G01 X121.732390 Y23.840980 Z-0.125000
G00 Z5.000000(End cutting pEth id: pEth846)
(Footer)
M5
G00 X0.0000 Y0.0000
M2
(Using defEult footer. To Edd your own footer creEte file “footer” in the output dir.)
(end)
% -
I need a macro or a script
Then you need to write one.
Macros cannot do math, so you would have to use a script.
If you search for
add_1
in the forum, you will find examples in the forum of people using PythonScript plugin, and the python interpreter that it provides Notepad++, to do simple math (the example adds 1 to a matched number; you would just have to multiply by 180/3.14159265 instead of adding 1). (The add_1 example is actually found in the PythonScript documentation, so if you install PythonScript using the Plugins Admin, then pull up the HELP in the Plugins>PythonScript menu, you can find the add_1 example there.) -
Thank you for your answer
I solved the conversion of rad2deg in g-gode tools by adding the 4th axis scale value 57.2992700729927.
Now, after each line with the A command, I need to add a line:
G4 S1
I guess it can do a macro, but I don’t know how? -
@marek-kuleta said in Gcode convert rad2deg:
Now, after each line with the A command, I need to add a line:
G4 S1
I guess it can do a macro, but I don’t know how?Well someone can help with that, since there isn’t any calculation the use of regular expressions should do the edit. But you need to read one of our FAQ posts on how to insert example data. Read this post.
It’s very important to insert the examples in the manner shown as your example above shows everything left justified, very likely that isn’t the reality of what you actually have. that’s the most common problem we have, data we cannot rely on being accurate.So insert example data as before the edit, and then show the same example data with how you want the edit to work, so the afterwards view.
Terry
-
Fragment of the g-code file before the change:
G00 Z1.500000 G00 X117.312930 Y58.656480 G01 A-90.00548759630999 G01 Z-0.300000 F500.0(Penetrate) G02 X110.084140 Y41.100850 Z-0.300000 I-24.931947 J0.000002 F2000.000000 A-134.7684809236628 G01 A-134.7684809236628 G02 X92.735046 Y33.872060 Z-0.300000 I-17.349097 J17.204522 A-180.01095886459603 G01 A-180.0109682682962 G02 X75.385950 Y41.100850 Z-0.300000 I0.000001 J24.433312 A-225.25344864784924 G01 A-225.25344864784932 G02 X68.157160 Y58.656480 Z-0.300000 I17.703157 J17.555632 A-270.016444395686 G01 A-270.0164535136815 G02 X75.385950 Y76.212110 Z-0.300000 I24.931947 J-0.000002 A-314.7794491948609
fragment of g-code file after change:
00 Z1.500000 G00 X117.312930 Y58.656480 G01 E-90.00548759630999 G4 S1 G01 Z-0.300000 F500.0(PenetrEte) G02 X110.084140 Y41.100850 Z-0.300000 I-24.931947 J0.000002 F2000.000000 E-134.7684809236628 G01 E-134.7684809236628 G4 S1 G02 X92.735046 Y33.872060 Z-0.300000 I-17.349097 J17.204522 E-180.01095886459603 G01 E-180.0109682682962 G4 S1 G02 X75.385950 Y41.100850 Z-0.300000 I0.000001 J24.433312 E-225.25344864784924 G01 E-225.25344864784932 G4 S1 G02 X68.157160 Y58.656480 Z-0.300000 I17.703157 J17.555632 E-270.016444395686 G01 E-270.0164535136815 G4 S1 G02 X75.385950 Y76.212110 Z-0.300000 I24.931947 J-0.000002 E-314.7794491948609
.
-
So, your most recent request was help with:
Now, after each line with the A command, I need to add a line:
G4 S1But then your black-boxed data shows more transformation than that.
Really, nobody is going to dive in an help you if you can’t get your problem statement correct.
-
@alan-kilborn
I want to replace A with E and insert G4S1 after each E line -
Hello, @marek-kuleta, @terry-r, @alan-kilborn and All,
@marek-kuleta, in your fragment of g-code file after changes, there are two errors :
-
You missed the first
G
letter of the first line -
You wrongly replaced the
a
letter of the word Penetrate, between parentheses, by an uppercase letterE
( as you want to change any uppercaseA
letter with anE
letter, in your text )
So, I suppose that your expected AFTER text is rather :
G00 Z1.500000 G00 X117.312930 Y58.656480 G01 E-90.00548759630999 G4 S1 G01 Z-0.300000 F500.0(Penetrate) G02 X110.084140 Y41.100850 Z-0.300000 I-24.931947 J0.000002 F2000.000000 E-134.7684809236628 G01 E-134.7684809236628 G4 S1 G02 X92.735046 Y33.872060 Z-0.300000 I-17.349097 J17.204522 E-180.01095886459603 G01 E-180.0109682682962 G4 S1 G02 X75.385950 Y41.100850 Z-0.300000 I0.000001 J24.433312 E-225.25344864784924 G01 E-225.25344864784932 G4 S1 G02 X68.157160 Y58.656480 Z-0.300000 I17.703157 J17.555632 E-270.016444395686 G01 E-270.0164535136815 G4 S1 G02 X75.385950 Y76.212110 Z-0.300000 I24.931947 J-0.000002 E-314.7794491948609
In this case, here is a possible regex solution :
-
Open the Replace dialog (
Ctrl + H
) -
SEARCH
(?-is)^G\d\d A.+\R
-
REPLACE
$0G4 S1\r\n
( or$0G4 S1\n
if you work with UNIX files ) -
Untick All options
-
Tick the
wrap around
option -
Select the
Regular expression
search mode -
Click once, on the
Replace All
button
=> A line
G4 S1
is inserted after any line beginning with aG
, followed by two digits, aspace
char and an uppercase letterA
!Then apply this second obvious regex S/R :
-
SEARCH
(?-i)A
-
REPLACE
E
The two consecutive replacements does change the text :
G00 Z1.500000 G00 X117.312930 Y58.656480 G01 A-90.00548759630999 G01 Z-0.300000 F500.0(Penetrate) G02 X110.084140 Y41.100850 Z-0.300000 I-24.931947 J0.000002 F2000.000000 A-134.7684809236628 G01 A-134.7684809236628 G02 X92.735046 Y33.872060 Z-0.300000 I-17.349097 J17.204522 A-180.01095886459603 G01 A-180.0109682682962 G02 X75.385950 Y41.100850 Z-0.300000 I0.000001 J24.433312 A-225.25344864784924 G01 A-225.25344864784932 G02 X68.157160 Y58.656480 Z-0.300000 I17.703157 J17.555632 A-270.016444395686 G01 A-270.0164535136815 G02 X75.385950 Y76.212110 Z-0.300000 I24.931947 J-0.000002 A-314.7794491948609
into this one :
G00 Z1.500000 G00 X117.312930 Y58.656480 G01 E-90.00548759630999 G4 S1 G01 Z-0.300000 F500.0(Penetrate) G02 X110.084140 Y41.100850 Z-0.300000 I-24.931947 J0.000002 F2000.000000 E-134.7684809236628 G01 E-134.7684809236628 G4 S1 G02 X92.735046 Y33.872060 Z-0.300000 I-17.349097 J17.204522 E-180.01095886459603 G01 E-180.0109682682962 G4 S1 G02 X75.385950 Y41.100850 Z-0.300000 I0.000001 J24.433312 E-225.25344864784924 G01 E-225.25344864784932 G4 S1 G02 X68.157160 Y58.656480 Z-0.300000 I17.703157 J17.555632 E-270.016444395686 G01 E-270.0164535136815 G4 S1 G02 X75.385950 Y76.212110 Z-0.300000 I24.931947 J-0.000002 E-314.7794491948609
Best Regards,
guy038
-
-
Thank you very much for your help and time. Good health !!!