Wednesday, October 18, 2017

Extracting CAD from PDFs

While creating documentation of a pinout for a project I discovered that what I thought was an image of the connectors for the enclosure I was using actually had a lot more to it than meets the eye.

Source PDF:
Tools Used: Foxit PhantomPDF editor, Inkscape, SolidWorks

Selecting the face view that I wanted revealed that this was an object, not a picture. What's more, there were hidden elements to the object:

It turns out that there were three different views of each of the connector options hidden in the object. I wasn't able to do much with the object in PhantomPDF, so I opened the pdf in Inkscape. From there I was able to make all of the items items visible, and copy the object to a new file and export it to a .png, .svg, and most usefully, a .dxf

This was especially useful because the manufacturer didn't have any CAD models of the enclosure on their website. With a DXF it's a straightforward process to import the data into a SolidWorks sketch. Using the dimensions in the 2D mechanical drawings provided, you can scale the DXF to the correct size. You can then reconstruct a 3D model from the sketches

While in this case (no pun intended) you probably could have created a workable CAD model from the 2D drawings by themselves, it is interesting to see how much data can be extracted from a PDF of a product brochure. It is also possible to get a DXF from this PDF even if the connector view was an image using some contour tracing methods, but this would likely take longer and may not produce as good of a result.

Note: Many manufacturers have user agreements that forbid the extraction of data for the purposes of design reconstruction/reverse engineering. This was not the case with this enclosure at the time of this writing. This post should not be taken as an endorsement of such behavior, and is intended for educational purposes only.