in what file can I set the rules of formation of text g-code, which I see on the button Path inspect

Here's the place for discussion related to CAM/CNC and the development of the Path module.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
memfis
Posts: 586
Joined: Tue Nov 15, 2016 7:58 pm

in what file can I set the rules of formation of text g-code, which I see on the button Path inspect

Post by memfis »

colleagues,


Вот уж казалось бы не мне вам, а вам мне следует to tell about the great importance of formatting code text with indents - with all the obviousness. I have long noticed that the generated g-code should also be formatted with indents. The logic is simple - unlike python code, g-code contains the same kind of instructions on every line, which should be "collapsed" as blocks of code when editing etc. Now I have to do it over and over again for each separate operation, manually - open the preview of the operation + select all + copy + go to Geany + paste + ctrl + shift + arrow up + set the indentation + move up a block + reduce the indentation of the block name + move to the end, ready to accept the next block of code.

Please tell me where, in what file can I set the rules of formation of text g-code, which I see on the button Path inspect
Attachments
Снимок экрана от 2022-07-04 16-36-10.jpg
Снимок экрана от 2022-07-04 16-36-10.jpg (316.26 KiB) Viewed 1064 times
chrisb
Veteran
Posts: 53945
Joined: Tue Mar 17, 2015 9:14 am

Re: in what file can I set the rules of formation of text g-code, which I see on the button Path inspect

Post by chrisb »

memfis wrote: Mon Jul 04, 2022 1:31 pm Please tell me where, in what file can I set the rules of formation of text g-code, which I see on the button Path inspect
It's in the postprocessor of your choice, so you can adapt it to your liking and it will even survive FreeCAD updates.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
Russ4262
Posts: 941
Joined: Sat Jun 30, 2018 3:22 pm
Location: Oklahoma
Contact:

Re: in what file can I set the rules of formation of text g-code, which I see on the button Path inspect

Post by Russ4262 »

Afternoon,
The Path Inspect tool might not make use of Post Processor modules since it more or less presents the raw internal gcode of an operation. I am not 100% confident of this, but I think the inspect tool is independent of post processor modules. I will have to look at the code base to be sure.

Russell

Code: Select all

OS: Windows 10 Version 2009
Word size of FreeCAD: 64-bit
Version: 0.21.29419 +11 (Git)
Build type: Release
Branch: master_prs
Hash: 86110d745cfcc2301e00a55ff825e408ac4e661c
Python 3.8.10, Qt 5.15.2, Coin 4.0.1, Vtk 8.2.0, OCC 7.6.2
Locale: English/United States (en_US)
Installed mods: 
  * FC_SU
  * Z_MacroStartup
chrisb
Veteran
Posts: 53945
Joined: Tue Mar 17, 2015 9:14 am

Re: in what file can I set the rules of formation of text g-code, which I see on the button Path inspect

Post by chrisb »

Russ4262 wrote: Mon Jul 04, 2022 6:03 pm I think the inspect tool is independent of post processor modules.
You are right, of course. Sorry for the confusion.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
memfis
Posts: 586
Joined: Tue Nov 15, 2016 7:58 pm

Re: in what file can I set the rules of formation of text g-code, which I see on the button Path inspect

Post by memfis »

Absolutely does not depend on the post-processor (otherwise I would not have asked, because it has been reported many times before where the post-processor is).
This is the "raw" g-code. And that's where I'd like to correct it.
Russ4262
Posts: 941
Joined: Sat Jun 30, 2018 3:22 pm
Location: Oklahoma
Contact:

Re: in what file can I set the rules of formation of text g-code, which I see on the button Path inspect

Post by Russ4262 »

Evening.
I think you are looking for the PathInspect.py module, https://github.com/FreeCAD/FreeCAD/blob/master/src/Mod/Path/PathScripts/PathInspect.py

Have a nice week.
Russell
memfis
Posts: 586
Joined: Tue Nov 15, 2016 7:58 pm

Re: in what file can I set the rules of formation of text g-code, which I see on the button Path inspect

Post by memfis »

Russ4262 wrote: Tue Jul 05, 2022 5:33 am I think you are looking for the PathInspect.py module, https://github.com/FreeCAD/FreeCAD/blob/master/src/Mod/Path/PathScripts/PathInspect.py

Have a nice week.
Russell
Thanks for the link. In the end I didn't change the python file and here's why - anyway I "take" the generated code from this window to the text editor Geany, where I do typical conversions so that my code is "parametric" and takes less bytes. I do it with my own script, with sed command, taking into account the peculiarities of this particular project, and adding two commands to my script is easier (and more reasonable) than correcting the program code itself. By the way, I would like to mention typical, standard (for any build) FC glitches -

1. renaming of the created operations - here we create an operation and change its name on the left side of the project tree. The second, third, etc. By the end of the work, all operations have changed names on the left side of the tree. And on the button "inspection" - part of operations remains with the old names. It is guaranteed that the changed names will be applied when -
1.1. close/open file, or
1.2. open the whole job for editing and on the Workplane tab change the order of at least one operation
2. superfluous digits - well, you can assume the coordinate X with an accuracy of up to 6 decimal places, even if there is a limit of 0.001. But at the feed rate is completely unnecessary in each line point and six zeros. These are all specific bytes, which we are forced to rotate and occupy RAM. Considering that amateur machines are (often) controlled by LPT computers, i.e., obviously obsolete (as a rule), this is a sensitive issue.
2.1. repetitive data - same height, same Y, etc. Perhaps some CNCs require the whole package to be specified on each line. But at the postprocessor level it is possible to lighten the code.
2.2. repeated commands. For example, the same contour set by Engrave and Profile - in the first line in one case double Z command. This is unnecessary.
3. Non-compliance with FC requirements of the developer - here we explicitly set Z and see (from time to time) that the actual code is created +\-1-2 in the sixth decimal place. A small thing, but for my script it matters (in the sense of auto-replacement)

Code: Select all

sed -i 's/(/	(/' tmp 
sed -i 's/G/		G/' tmp 
sed -i 's/F25.000000/F[#<_pm>]/' tmp 
sed -i 's/F50.000000/F[#<_pb>]/' tmp 
sed -i 's/F100.000000/F[#<_pb>]/' tmp  
sed -i 's/K0.000000/ /' tmp 
#sed -i 's/Z20.000000/Z[#1]/' tmp
#sed -i 's/Z18.999999/Z[#1]/' tmp 
#sed -i 's/Z19.999999/Z[#1]/' tmp "


sed -i 's/Z19.111000/Z[#1]/' tmp 
sed -i 's/Z19.111001/Z[#1]/' tmp 
sed -i 's/Z15.100001/Z[#<_glr_p>]/' tmp 
sed -i 's/Z15.100000/Z[#<_glr_p>]/' tmp 
sed -i 's/Z19.123001/Z[#<_glr>]/' tmp 
sed -i 's/Z19.123000/Z[#<_glr>]/' tmp 

Attachments
Снимок экрана от 2022-07-07 23-21-39.jpg
Снимок экрана от 2022-07-07 23-21-39.jpg (309.88 KiB) Viewed 833 times
User avatar
sliptonic
Veteran
Posts: 3457
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: in what file can I set the rules of formation of text g-code, which I see on the button Path inspect

Post by sliptonic »

You're fundamentally misunderstanding and misusing the Inspect tool.
The tool is meant to show the contents of the Path Command objects in the operation. This is NOT the gcode. It is 'g-code like' but it's simply FreeCAD's internal representation. This is equivalent to the CL-data in other CAMs.

The entire point of a post-processor is to convert those commands into gcode. That's exactly what you're doing with your scripts but you're doing it in a really inefficient and klunky way.

Why not just write a custom post?
memfis
Posts: 586
Joined: Tue Nov 15, 2016 7:58 pm

Re: in what file can I set the rules of formation of text g-code, which I see on the button Path inspect

Post by memfis »

I beg to differ - in circumstances where the Path workbench doesn't even allow for grouping operations, the method I chose is fast, simple, and rational. We have an almost proverbial "вам шашечки или ехать?" (in the sense that when you call a cab and the car arrives without the special distinctive signs of a cab, will you refuse to go because there are no such signs or do you want a ride?) me = go. The resulting code in my edition has a structure that makes it easy to control the execution of the program in real work. For example, and this has already been discussed, the feed rate - FC fixes it for each tool for the entire block of operations. In my case this is replaced by parameters, variables that I can change quickly from operation to operation and even already while the machine is running, without referring to FC, I am right "in the machine". I can add or decrease speed, instantly correct height of code execution and other "adjusting", "debugging" actions where necessary. The code structure allows to "minimize" the code and a file of tens of thousands of lines turns into several screens.
User avatar
sliptonic
Veteran
Posts: 3457
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: in what file can I set the rules of formation of text g-code, which I see on the button Path inspect

Post by sliptonic »

memfis wrote: Fri Jul 08, 2022 8:16 pm I beg to differ - in circumstances where the Path workbench doesn't even allow for grouping operations, the method I chose is fast, simple, and rational. We have an almost proverbial "вам шашечки или ехать?" (in the sense that when you call a cab and the car arrives without the special distinctive signs of a cab, will you refuse to go because there are no such signs or do you want a ride?) me = go. The resulting code in my edition has a structure that makes it easy to control the execution of the program in real work. For example, and this has already been discussed, the feed rate - FC fixes it for each tool for the entire block of operations. In my case this is replaced by parameters, variables that I can change quickly from operation to operation and even already while the machine is running, without referring to FC, I am right "in the machine". I can add or decrease speed, instantly correct height of code execution and other "adjusting", "debugging" actions where necessary. The code structure allows to "minimize" the code and a file of tens of thousands of lines turns into several screens.
Those are all cool features. They are things we all would like. Doing them based on the contents of the inspection dialog is the ridiculous part. You can get to all the same data in a postprocessor but also get much much more. In fact, there's nothing you can get from inspection dialog that isn't available during post.

The inspection dialog only shows a single operation, not the job as a whole. Going through the postprocessor allows you to do the output automatically on all the operations including duplicated operations if you're working with multiple WCS.
Post Reply