# What resolution (pixels/mm) should I use in SVGs for CNC

I am planning a mechanical 40% keyboard build and are coincidentally on the home stretch of a homemade CNC project.

The only thing the CNC needs to do for the keyboard project is to drill 7*48 holes. So what I need to do now is layout those holes in SVG. Therein lyes the question. What resolution should I use for the SVG. I want to space the center of the keyboard switches 19mm apart. An online pixel to mm converter suggested that 72 pixels is exactly 19.05mm (which actually is what Cherry MX says should be their spacing).

Now, I do understand that this really doesn't matter, but I am curious as I am new on CNCs and was suspecting that there is a number that will "just work".

Thanks.

• SVG is a vector format. I can be displayed at any arbitrary scale and doesn't have pixels (hence Scalable Vector Graphics). If you look at the file it's xml text. The file may contain meta data indicating a recommended viewing size in pixels per unit but an SVG can be in mm directly rather than in pixels. Dec 12, 2016 at 12:03
• That I know. But, when, for example, printing a SVG file with a regular printer the printers must already have to do an assumption about the pixel to mm ratio. What I was searching for was the default assumption and think of that as a "best practice" for what I should use when writing my own SVG. And, as proven by a printer test I just did, 72 pixels per 19.05 millimeters seems to be that default. I might be incorrect in calling it pixels though, maybe it should be called SVG units. Dec 12, 2016 at 20:20

I found one of those printer things that puts ink on dead trees and tested to print a simple SVG file.

<svg xmlns="http://www.w3.org/2000/svg"
width="400px" height="800px">
<rect x="10" y="10" width="72" height="72" fill="#999999" />
<rect x="10" y="100" width="378" height="378" fill="#999999" />
</svg>


As I suspected 72 pixels came out pretty much exactly 19mm. (72/19.05)*100~=378 came out 100mm.

Given this I am going to assume that 72/19.05 is the de facto best pixel to mm ratio to use for CNC projects.

EDIT:

Found this documentation: http://w3.org/TR/SVG/coords.html#Units

<svg xmlns="http://www.w3.org/2000/svg"
width="400px" height="800px">
<rect x="10" y="10" width="19.05mm" height="19.05mm" fill="#999999" />
<rect x="10" y="100" width="100mm" height="100mm" fill="#999999" />
</svg>


Much simpler to use mm as units right away

You should probably seek out a program that lets you use millimeters as units directly. Atleast Inkscape supports this for .svg files (select "default unit" in document properties), and of course all proper CAD programs do.

Failing that, you can pick any value as long as you remember it and apply proper scaling when doing the CAM work. If you are ordering the pieces from somewhere, you'll want to include a dimension drawing to make sure they come out the proper size.

• For this particular work I think it is a lot easier for me to write the SVG myself. Thanks for your input. It had me look for and find this that explains it. I was of course wrong to think of it as pixels instead of meaningless units. w3.org/TR/SVG/coords.html#Units Dec 12, 2016 at 20:25