Program to scale gcode

More
10 Mar 2018 02:22 #107181 by tim@home
So right after I started cutting gcode files with my router I noticed EMC had no scaling capabilities within the program, nor could I just tell EMC to "cut this code 3 times in succession lowering z by .125" each time" simply. I did notice that the EMC logo file that loads when EMC starts contained #scale = 1.0 that could be changed to any scale. I wanted those two features in my gcode - scaling and multipass cutting and I did not want to keep returning to Qcad to accomplish it. The attached is my solution - for me at least - and for anyone else that may be able to use it. It uses SED, the linux substitution editor to read a gcode file output by Qcad and insert the code to create the subroutine for multipass cutting as well as that ultra handy #scale component. Line 63 in the bash file is the form of the bash command to use in terminal. The parameters are on line 64 with explanations as comments. Just copy your gcode file into the same folder as the bash file and rename it to test.ngc. The output is test1.ngc. It works with output by Qcad but can be tweaked for other Cam output files I'm sure. PS because the .sh file extension is not an allowed type I have renamed it with .txt change it back and make it executable on your machine.
Attachments:
The following user(s) said Thank You: nkp, tommylight

Please Log in or Create an account to join the conversation.

More
10 Mar 2018 10:24 #107183 by tommylight
Replied by tommylight on topic Program to scale gcode
Inkscape has the option to export parametrized gcode for Linuxcnc, but changing the scale will also change the Z depth, it has no separate scales for XY and Z.
This is a nice addition.
Thank you.

Please Log in or Create an account to join the conversation.

More
18 Nov 2020 00:01 #189634 by lhenry
Replied by lhenry on topic Program to scale gcode
parameters aren't very clear in the file.
can you give an example of copy-paste command?
tnx

Please Log in or Create an account to join the conversation.

More
22 Nov 2020 16:08 #190056 by tim@home
Replied by tim@home on topic Program to scale gcode
The script is not of the cut and paste variety. Let me explain. The assumption for this script is that your gcode file was made with Qcad. If your file was made with another program adjustments to the script will be necessary on your end.
Let's say you have a gcode file named 'circle.gcode', for reference
Let's also assume you have created a directory at /home/Desktop/CNC/sed
Step 1 would be to copy the circle.gcode file to that directory and rename it 'test.txt'.
Step 2 would be to copy my 'Scale_cutall_combined.txt' file to that directory and rename it to 'Scale_cutall_combined.sh' and make it executable.
Now in a terminal cd into the directory and paste:

bash Scale_cutall_combined.sh test.txt test1.txt \#\<scale\>\] 2 .250

paste the above exactly making no changes. The scale will be set in the file created.
This would be good for 1/2" plywood.
Now say you have 3/8" material and you want to cut it in 3 passes of .125" each. The command now is:

bash Scale_cutall_combined.sh test.txt test1.txt \#\<scale\>\] 3 .125

This first command will run the bash script on your test.txt file you renamed earlier.
It outputs a file named 'test1.txt' which is both scale-able and will cut your circle into 1/2" plywood in 2 passes of .250" on each pass.
The file 'test1.txt' now needs to moved to a new directory for example /home/Desktop/CNC/Scaled and renamed, for example 'Scaled_circle.gcode'
The file is then run in LinuxCNC and depending on how it looks on the table you decide whether to scale up or down.
To change the scale open 'Scaled_circle.gcode' in gedit and near the top you'll see where the scale is declared. The default is 1.
Change the scale as needed, save the file and reload it into LinuxCNC. Repeat until you achieve the scale you need.
I hope this helps.

Please Log in or Create an account to join the conversation.

Time to create page: 0.111 seconds
Powered by Kunena Forum