2D solution: QCAD plus python script

alpha
Posts: 174
Joined: Thu Apr 12, 2012 2:49 pm

2D solution: QCAD plus python script

Post by alpha » Mon Apr 23, 2012 2:54 pm

Hello,

I wanted to share my workflow for cutting some shape with holes and several passes.
You may want to watch this in HD and full screen to be able read!


http://www.youtube.com/watch?v=UU5HcDbzUkg



Old post before I added the video:
I used QCAD http://www.ribbonsoft.com/en/qcad on Linux (free GPL version that comes with Ubuntu/Mint) before and it is pretty easy. So I was looking if there is a way to use this and I found this video: http://www.youtube.com/watch?v=CQRpKdKG46M
Looks like this script http://code.google.com/p/dxf2gcode/ takes the file from QCAD and converts it to GCODE. I did test this without EMC and it creates a text file with GCODE. However, I don't have the hardware and I'm not sure if this GCODE will work.

Are there any commands in this GCODE (I recreated the part from the video) that would cause any issues:
100mm x 100mm square
hole in each corner (center of hole is 20mm x 20mm from corner) with radius=10mm
I did select the parts but I didn't change any settings.

Code: Select all

(Generated with: dxf2gcode_b02, Version: TKINTER Beta 02, Date: 2010-05-04)
(Time: Mon Apr 23 09:41:33 2012)
(Created from file: /home/markus/Desktop/test.dxf)
G21 (Unit in mm)
G90 (Absolute distance mode)
G64 P0.01 (Exact Path 0.001 tol.)
G17
G40 (Cancel diameter comp.)
G49 (Cancel length comp.)
T1M6 (Tool change to T1)
M8 (Coolant flood on)
S5000M03 (Spindle 5000rpm cw)
G0 Z  15.000 
G0 X  12.929 Y  12.929
G0 Z   3.000 
F150
G1 Z  -1.500
F400
G2 X  27.071 Y  27.071 I   7.071 J   7.071
G2 X  12.929 Y  12.929 I  -7.071 J  -7.071
F150
G1 Z  -3.000
F400
G2 X  27.071 Y  27.071 I   7.071 J   7.071
G2 X  12.929 Y  12.929 I  -7.071 J  -7.071
G1 Z   3.000
G0 Z  15.000 
G0 X  12.929 Y  72.929
G0 Z   3.000 
F150
G1 Z  -1.500
F400
G2 X  27.071 Y  87.071 I   7.071 J   7.071
G2 X  12.929 Y  72.929 I  -7.071 J  -7.071
F150
G1 Z  -3.000
F400
G2 X  27.071 Y  87.071 I   7.071 J   7.071
G2 X  12.929 Y  72.929 I  -7.071 J  -7.071
G1 Z   3.000
G0 Z  15.000 
G0 X   0.000 Y 100.000
G0 Z   3.000 
F150
G1 Z  -1.500
F400
G1 X   0.000 Y   0.000
G1 X 100.000 Y   0.000
G1 X 100.000 Y 100.000
G1 X   0.000 Y 100.000
F150
G1 Z  -3.000
F400
G1 X   0.000 Y   0.000
G1 X 100.000 Y   0.000
G1 X 100.000 Y 100.000
G1 X   0.000 Y 100.000
G1 Z   3.000
G0 Z  15.000 
G0 X  72.929 Y  72.929
G0 Z   3.000 
F150
G1 Z  -1.500
F400
G2 X  87.071 Y  87.071 I   7.071 J   7.071
G2 X  72.929 Y  72.929 I  -7.071 J  -7.071
F150
G1 Z  -3.000
F400
G2 X  87.071 Y  87.071 I   7.071 J   7.071
G2 X  72.929 Y  72.929 I  -7.071 J  -7.071
G1 Z   3.000
G0 Z  15.000 
G0 X  72.929 Y  12.929
G0 Z   3.000 
F150
G1 Z  -1.500
F400
G2 X  87.071 Y  27.071 I   7.071 J   7.071
G2 X  72.929 Y  12.929 I  -7.071 J  -7.071
F150
G1 Z  -3.000
F400
G2 X  87.071 Y  27.071 I   7.071 J   7.071
G2 X  72.929 Y  12.929 I  -7.071 J  -7.071
G1 Z   3.000
G0 Z  15.000 
G0 X   0.000 Y   0.000
M9 (Coolant off)
M5 (Spindle off)
M2 (Prgram end)
Anybody think this would be a good solution for Linux (I guess it should also work for Windows and Mac, but QCAD is not free)?
Last edited by alpha on Fri Jul 13, 2012 2:24 am, edited 3 times in total.

edwardrford
Posts: 1250
Joined: Mon Apr 09, 2012 5:40 pm
Location: Dixon, IL
Contact:

Re: 2D solution?: QCAD plus DXF2GCODE

Post by edwardrford » Mon Apr 23, 2012 3:15 pm

I ran the gcode through cncsimulator, and it appears to work as expected. However, the operation order is not the most efficient, and does not go by best practices.

Let me explain: When you're cutting a perimeter (the 200x200mm box) which has work done inside of it (the circles), you want to do the inside work first, and then cut the perimeter as the last operation.

If you cut the perimeter before all the other operations are done, then your piece will more than likely move and your inside work will not be relative to the rest of the part. PLUS, your part has a really great chance of flying across the room as there's nothing left to hold it down!

Here's a screenshot of cnc simulator running the job. You can tell that it cut the two circles on the left of the part first, then cut the perimeter, then came back and cut the two circles on the right.

Is there something in dxf2gcode that allows you to select the order of operations? Perhaps by layer?
qcad_test.png
qcad_test.png (46.91 KiB) Viewed 3700 times
-Edward
Shapeoko 1 #0 - a couple of upgrades.
Shapeoko 2 #0 - a couple of upgrades.
Shapeoko 3 #2 - Stock

alpha
Posts: 174
Joined: Thu Apr 12, 2012 2:49 pm

Re: 2D solution?: QCAD plus DXF2GCODE

Post by alpha » Mon Apr 23, 2012 6:11 pm

Thanks for the simulation! I guess DXF2GCODE could be used with two exports, it is possible to hide objects.
There are other DFX to GCODE tools like Pycam http://pycam.sourceforge.net/download.html that at least in this case it create a better order. However the GCODE looks different, like 100 more lines of GCODE. Is this better or worse?

Code: Select all

;PYCAM-META-DATA: Filename: /home/markus/Desktop/test.dxf
;PYCAM-META-DATA: Timestamp: 2012-04-23 13:59:31.618994
;PYCAM-META-DATA: Version: 0.5.1
;Estimated machine time: 6 minutes
G40 (disable tool radius compensation)
G49 (disable tool length compensation)
G80 (cancel modal motion)
G54 (select coordinate system 1)
G90 (disable incremental moves)
G21 (metric)
G61 (exact path mode)
F200.00000
S1000.00000
;PYCAM_TOOLPATH_SETTINGS: START
;[Bounds]
;maxz = 0.0
;maxx = 109.5
;maxy = 109.5
;minx = -9.5
;miny = -9.5
;minz = 0.0
;
;[Tool]
;torus_radius = 0.25
;speed = 1000.0
;shape = SphericalCutter
;tool_radius = 0.5
;feedrate = 200.0
;
;[Process]
;engrave_offset = 0.0
;step_down = 1.0
;generator = EngraveCutter
;postprocessor = SimpleCutter
;overlap_percent = 0
;milling_style = conventional
;material_allowance = 0.0
;pocketing_type = none
;path_direction = x
;
;PYCAM_TOOLPATH_SETTINGS: END
T3 M6
G0 Z25.0000
M3 (start spindle)
G04 P3 (wait for 3 seconds)
 X30.0000 Y20.0000
G1 Z0.0000
 X29.8079 Y18.0491
 X29.2388 Y16.1732
 X28.3147 Y14.4443
 X27.0711 Y12.9289
 X25.5557 Y11.6853
 X23.8268 Y10.7612
 X21.9509 Y10.1921
 X20.0000 Y10.0000
 X18.0491 Y10.1921
 X16.1732 Y10.7612
 X14.4443 Y11.6853
 X12.9289 Y12.9289
 X11.6853 Y14.4443
 X10.7612 Y16.1732
 X10.1921 Y18.0491
 X10.0000 Y20.0000
 X10.1921 Y21.9509
 X10.7612 Y23.8268
 X11.6853 Y25.5557
 X12.9289 Y27.0711
 X14.4443 Y28.3147
 X16.1732 Y29.2388
 X18.0491 Y29.8079
 X20.0000 Y30.0000
 X21.9509 Y29.8079
 X23.8268 Y29.2388
 X25.5557 Y28.3147
 X27.0711 Y27.0711
 X28.3147 Y25.5557
 X29.2388 Y23.8268
 X29.8079 Y21.9509
 X30.0000 Y20.0000
G0 Z25.0000
 X90.0000
G1 Z0.0000
 X89.8079 Y18.0491
 X89.2388 Y16.1732
 X88.3147 Y14.4443
 X87.0711 Y12.9289
 X85.5557 Y11.6853
 X83.8268 Y10.7612
 X81.9509 Y10.1921
 X80.0000 Y10.0000
 X78.0491 Y10.1921
 X76.1732 Y10.7612
 X74.4443 Y11.6853
 X72.9289 Y12.9289
 X71.6853 Y14.4443
 X70.7612 Y16.1732
 X70.1921 Y18.0491
 X70.0000 Y20.0000
 X70.1921 Y21.9509
 X70.7612 Y23.8268
 X71.6853 Y25.5557
 X72.9289 Y27.0711
 X74.4443 Y28.3147
 X76.1732 Y29.2388
 X78.0491 Y29.8079
 X80.0000 Y30.0000
 X81.9509 Y29.8079
 X83.8268 Y29.2388
 X85.5557 Y28.3147
 X87.0711 Y27.0711
 X88.3147 Y25.5557
 X89.2388 Y23.8268
 X89.8079 Y21.9509
 X90.0000 Y20.0000
G0 Z25.0000
 Y80.0000
G1 Z0.0000
 X89.8079 Y78.0491
 X89.2388 Y76.1732
 X88.3147 Y74.4443
 X87.0711 Y72.9289
 X85.5557 Y71.6853
 X83.8268 Y70.7612
 X81.9509 Y70.1921
 X80.0000 Y70.0000
 X78.0491 Y70.1921
 X76.1732 Y70.7612
 X74.4443 Y71.6853
 X72.9289 Y72.9289
 X71.6853 Y74.4443
 X70.7612 Y76.1732
 X70.1921 Y78.0491
 X70.0000 Y80.0000
 X70.1921 Y81.9509
 X70.7612 Y83.8268
 X71.6853 Y85.5557
 X72.9289 Y87.0711
 X74.4443 Y88.3147
 X76.1732 Y89.2388
 X78.0491 Y89.8079
 X80.0000 Y90.0000
 X81.9509 Y89.8079
 X83.8268 Y89.2388
 X85.5557 Y88.3147
 X87.0711 Y87.0711
 X88.3147 Y85.5557
 X89.2388 Y83.8268
 X89.8079 Y81.9509
 X90.0000 Y80.0000
G0 Z25.0000
 X30.0000
G1 Z0.0000
 X29.8079 Y78.0491
 X29.2388 Y76.1732
 X28.3147 Y74.4443
 X27.0711 Y72.9289
 X25.5557 Y71.6853
 X23.8268 Y70.7612
 X21.9509 Y70.1921
 X20.0000 Y70.0000
 X18.0491 Y70.1921
 X16.1732 Y70.7612
 X14.4443 Y71.6853
 X12.9289 Y72.9289
 X11.6853 Y74.4443
 X10.7612 Y76.1732
 X10.1921 Y78.0491
 X10.0000 Y80.0000
 X10.1921 Y81.9509
 X10.7612 Y83.8268
 X11.6853 Y85.5557
 X12.9289 Y87.0711
 X14.4443 Y88.3147
 X16.1732 Y89.2388
 X18.0491 Y89.8079
 X20.0000 Y90.0000
 X21.9509 Y89.8079
 X23.8268 Y89.2388
 X25.5557 Y88.3147
 X27.0711 Y87.0711
 X28.3147 Y85.5557
 X29.2388 Y83.8268
 X29.8079 Y81.9509
 X30.0000 Y80.0000
G0 Z25.0000
 X0.0000 Y0.0000
G1 Z0.0000
 Y100.0000
 X100.0000
 Y0.0000
 X0.0000
G0 Z25.0000
M5 (stop spindle)
G04 P3 (wait for 3 seconds)
G0 Z25.0000
M2 (end program)


nogthree
Posts: 62
Joined: Mon Apr 09, 2012 8:48 pm
Location: Brisbane, Australia
Contact:

Re: 2D solution: QCAD plus python script

Post by nogthree » Mon Apr 23, 2012 11:45 pm

Edward, out of curiosity how did you get CNCsimulator to respect the bed size of the shapeoko and run without specified tools?

It always seems to fall over on the helloworld code for me on those issues.
- Brendan Halliday.
ShapeOko Wiki Userpage

edwardrford
Posts: 1250
Joined: Mon Apr 09, 2012 5:40 pm
Location: Dixon, IL
Contact:

Re: 2D solution: QCAD plus python script

Post by edwardrford » Tue Apr 24, 2012 4:20 pm

I started using cncsimulator a few years back and ran into the same issues regarding tooling and material size. However, after beating my head against the wall I was eventually able to figure out how to properly operate the software:

Steps:
1.) Click Simulator -> Detail Settings
2.) Set your material dimensions. NOTE: this will be interpreted to whatever units your *job* is set to. So, if your job is set to 'inches' type in your material size in inches!
3.) If you want to start your job in the middle of the material, put half the width/heigh in the X/Y nullpoint fields.
4.) Click 'OK'
5.) Click Simulator -> Edit Tools
6.) Setup tool 31 and 32 as shown below.
cs_tools.png
cs_tools.png (36.59 KiB) Viewed 3638 times
7.) In your job, be sure to edit the T0 to coincide with whatever unit you are using to run the job. i.e. if you're running a metric job, use T32 if you're running an imperial job use T31.
8.) Again, the tool specifications (diameter and length, etc) will be interpreted as whatever unit your job is specified (G20 or G21)

That should do it!
Shapeoko 1 #0 - a couple of upgrades.
Shapeoko 2 #0 - a couple of upgrades.
Shapeoko 3 #2 - Stock

alpha
Posts: 174
Joined: Thu Apr 12, 2012 2:49 pm

2.5D solution: Inkscape plus Pycam

Post by alpha » Sat Apr 28, 2012 3:32 am

Have a look at this advanced 2.5d work flow http://vimeo.com/21502122
It uses inkscape and pycam to generate differnt depth.

atanguay
Posts: 36
Joined: Wed Jun 20, 2012 4:26 am

Re: 2D solution: QCAD plus python script

Post by atanguay » Sun Jul 08, 2012 12:19 am

Alpha-

Can you explain what you did to get PyCam to work with Inkscape?

I'm getting complaints about PSTOEDIT and all this stuff. I'm not too sure how these things click together.
But this looks like a nice simple solution.
SHAPEOKO SERIAL NUMBER 303! - Home of the ShapeoKube!

alpha
Posts: 174
Joined: Thu Apr 12, 2012 2:49 pm

Re: 2D solution: QCAD plus python script

Post by alpha » Sun Jul 08, 2012 1:22 am

Sorry - I never used Inkscape and Pycam together, only QCAD and PyCam... once ;)
I just found that video, but I think AtomSoft had some issues with Inkscape... looks like there are some g-code export functions that don't work like he liked it...
Have a look at QCAD or the fork Librecad, I like it and it works good. :D

swordman
Posts: 9
Joined: Sat Jul 07, 2012 5:29 pm

Re: 2D solution: QCAD plus python script

Post by swordman » Mon Jul 09, 2012 7:46 am

@atanguay:
I had the same issues at first :) I'm talking about using pycam on windows, I haven't tryed it on linux yet.The main problem there is that on the site they don't discuss clearly that you need to install some dependencies.
If I reall it right, I had to install:
- Inkscape (if you want to have it auto-indetified, or you can use the portable verison setting up tha path manualy)
- PstoEdit (http://www.pstoedit.net/)
- GhostScript (http://www.ghostscript.com/download/gsdnld.html)
- ImageMagic DLL for windows (http://image_magick.veidrodis.com/image_magick/binaries/)
(I don't recall if I had to restart after the installation of ImageMagic for it to get recognized).

whne you have installed all the dependencies, you can draw your image in Inkscape and save it as SVG.
Then you can open pyCam and open the SVG with it (you can also do drag-and-drop). Sometime I get an error relative to DXF import, I just close pyCam the reopen it and reload the file.
If you ned more help, just ask ;)

atanguay
Posts: 36
Joined: Wed Jun 20, 2012 4:26 am

Re: 2D solution: QCAD plus python script

Post by atanguay » Tue Jul 10, 2012 4:26 pm

@swordman-

Yeah, I was running in to those issues, one after another. Then tried to rectify them, without success. In the end I'm wondering if it's because I'm on 64bit XP on the machine I'm using for this stuff. Maybe that doesn't make one of the dozen components happy. 8-)

I will try again because I like the relative simplicity of a workflow that's '1-Draw something in vector 2-paste it to a CAM program 3-cut it with GRBL/Shapeoko'. I want it to be more of a tool than a chore to setup.

Thanks for the info alpha and swordman
SHAPEOKO SERIAL NUMBER 303! - Home of the ShapeoKube!

Post Reply