Solidworks tip – scanning and importing

One very useful technique in Solidworks for designing parts to fit other parts that already exist is to use a flatbed scanner or other calibrated input device to make your model match critical dimensions with a reduced amount of getting out the calipers and making detailed measurements. Flatbed scanners are particularly useful for scanning printed circuit boards or parts of a chassis that can be laid flat on the scanner.

One of the difficult things though is getting the scale just right. When you have to start scaling the photograph to match certain measurements you introduce opportunity for errors. Even small errors can be frustrating because you’ll be tweaking the model a lot to match reality.

A flatbed scanner isn’t the “perfect” device though, and many of them have issues with distortion since most of the time you’re not scanning something that’s completely flat. The optics and scanning/digitizing methods vary greatly. I’ve found that some of the cheaper scanners found in the “all in one” types of devices like scanner/printer/fax machines don’t have great depth of field and do weird things when the object being scanned is not a flat document.

Back to the scaling issue. Wouldn’t it be nice to just not have to scale anything manually, to have it come in just perfect? It should be easier, but it is certainly possible with a tiny bit of work. A little experimentation may be needed. Once you’ve got it down, you can re-use the technique over and over.

I’ll give you an example. As a test, I created a 1 inch square bitmap using Adobe Photoshop and loaded it into Solidworks.

sketch-pictureSketch picture command in lower right of image

 sketch-picture-size

What Solidworks thinks it should be.

Look at that! My 1 inch square image gets interpreted as 39.37 inches. This will not do.

Now if you’ve been doing a few metric conversions, you may notice that 39.37 seems familiar. That’s the number of inches in 1 meter. So it would almost seem that Solidworks thinks my square is 1 meter instead of 1 inch. I did some experimentation and it seems that the DPI setting in photoshop has no effect. Whether it’s 72 DPI or 1000 DPI, my 1 inch square shows up as 39.37 inches when it’s 1000 pixels across. Put another way, 1 pixel = 1mm.

So if it’s based on pixels, I should be able to just scale down my image so for instance my 1000 pixel square divided by 39.73 would become 25.4 pixels square. Well that’s pretty chunky, and any scanned images aren’t going to look too great at 25.4 DPI. Besides, I want to take advantage of the native resolution of my scanner as much as practical so I get a nice looking image.

One way around this is pretty simple. I’ll just scan at some multiple of 25.4 pixels per inch, then scale it down in Solidworks by a constant factor. So, I chose a multiple of 20. Using a 508 DPI setting (25.4 x 20) on my scanner will let me divide by 20 in Solidworks, get the scale right, and maintain a decent image.

The image below is of a mouse pcb loaded into a sketch. I put it on the scanner, scanned at 508 DPI, loaded it into Solidworks, and voila, the scale came out right and it looks nice. In the photo below you can see how I simply entered an equation in the Solidworks field for X dimension. You can enter equations like this and Solidworks does the math.

Solidworks-image-scaling Entering an equation. Note the “/20” highlighted in red.

Solidworks-image-scaling-afterFinal result after scaling… just what we want.

There may be other tricks to accomplish this, but this is pretty straightforward. A quick measurement between 2 points on the drawing and the same 2 points on the physical pcb show an accurate match. Now I can proceed with building the model around this board!

I hope you’ve found this useful, and if you have other techniques to do this, I’d love to hear them.




Leave a Reply

You must be logged in to post a comment.