I am occasionally working on a python script to take an image and turn

I am occasionally working on a python script to take an image and turn it into a rough cut tool path.
Is 1x1x1 mm resolution too fine for cutting wood?
I am thinking I might set it to 1mm x,y resolution by 2mm z resolution. I imagine that according to how powerful your mill is vs the material, this would need to be adjustable. Currently, I have about 14 hours worth of cut time according to chilipeppr.

I’m afraid I can’t answer your question… but I like the project… I’d be interested in seeing your script… I have some students who might like to tackle a similar project.

have a look at this https://github.com/aewallin/opencamlib

@Miguel_Sanchez ​ I guess the link will be more useful to @Colleen_McGuire ​​ than me. I am doing the coding for the fun of it. The value of my code would be how it is simple and obvious that I am messing around and trying to have fun with it while trying out different methods. It is more fun for me to figure stuff out on my own than to copy.

Yes, My kids are working in Python right now and I have a small shapeoko as well as a minikossel in progress. Thought the python script might be a neat project for them…didn’t know if there was a similar Python library for the conversions to gcode.

It sounds like the link Miguel gave does a full CAD to gcode conversion. My script is much much simpler and just changes an image to gcode. The point of mine is to take care to not cut too deep in one pass while trying to get the desired total depth before the final cut. I will probably never get it to a “completed” version because I am just screwing around. It is getting close to a “useful” version though.

I actually started an Img2Gcode ChiliPeppr widget a while back and it was all Javascript. It would take a PNG/JPG/GIF and let Javascript read in the image and I would go over the array of pixels and generate Z depths off of the pixel gray value. I let the user pick the high Z for white and low Z for black and I generated the Z’s in the middle. I was going to let the user pick how tall and wide the overall image was supposed to be in the final gcode. Then I was going to let them pick the end mill size and use that as the method of deciding how wide of paths to make which is the part that answers your original question. Hope that gives you some ideas.

@NathanielStenzel @Colleen_McGuire I have done a similar project myself but for STL volumes, but when you factor in the non-neglible dimension of the milling bit and you want to do parallel finish instead of waterline milling things start to get interesting (or nasty, depending on your pain threshold :-). Ander’s blog is full of insight as he has being there before (for example http://www.anderswallin.net/2010/10/adaptive-sampling-drop-cutter/ ) and this other site I have found very interesting too http://www.freesteel.co.uk/wpblog/

I do have a ShapeOko but my work is aimed mostly at larger CNC machines for milling polystyrene sculptures (tens of feet tall) like the ones used in the movies and theme parks.

2D milling bit compensation can be done easily with polygon offsets (like clipper library) but for 3D milling I needed to read a bunch of papers to get up to speed. Challenging but fun.

@jlauer ​ mine is in python. It does give me some ideas. The resolution of my milling grid is probably something that some experience would be useful for choosing though. That reminds me…I should consider the option of avoiding cutting on a side of the bit when the cutting edge is moving with/against the bit movement.
What is the status on your project, by the way?

My project is dead while I continue to work on the core SPJS buffering and perfection.

Have you tried the image vectorizer app in Easel?

@Ruwan_Janapriya I think I tried Easel, but not the image vectorizer app.

@Colleen_McGuire https://github.com/nathanielstenzel/bucket_mill I just got around to putting the code out there. It is a mess, there is no doubt about it, but that code now gets interesting results. Just don’t count on the scanline algorithm working.

I think your setting of speed without an axis may not work well on some machines. I reckon Z-axis and XY-axis are handled as two different speeds on some controllers so you may want to set each of them independently. Other than that Python code always looks cleaner than C++ or Java :slight_smile:

Thanks so much for sharing!

@Miguel_Sanchez do you have an example of a z speed and an X and/or you speed setting? I do not know how to set the speeds separately.

G1 Z10 F1000 sets the z speed
G1 X100 Y100 F2900 sets th xy speed

@Miguel_Sanchez thanks much

@Miguel_Sanchez ​ come to think of it, doesn’t this mean that if you want to move in x, you AND z that you must set it at the slower of the speeds? It sounds like a weakness in the firmware that the 3d printers do not have.

@NathanielStenzel Some CNC machines are used for 2D machining only, so CAM software won’t do joint XYZ moves, just XY or Z moves independently, using the so-called plunge-rate for the Z and the desired feed rate for XY moves.