Aug 29, 2011

How to work with pdf files with ARES CE,Bricscad,DraftSight and Librecad

Importing PDF files is a missing feature from all Linux CAD packages. However there are some very interesting and simple workarounds to bypass this problem.
  1. Converting  PDF to PNG or JPEG
This is very easy with GIMP. And is the only way you can work with scanned pdf drawings. Just open the pdf file with GIMP and save the file as .png or jpg. Needs some attention only when you choose the image quality. Very low quality images may not be clear when you zoom and very high quality images may slow down your CAD program (especially Bricscad which has poor raster performance).

The PDF file

The save as png dialog box in GIMP

The png file imported to DraftSight

   2. Converting PDF to DXF
If your pdf file has been exported from a CAD program the best way to work with it is to convert it to dxf.
Inkscape has a save as dxf option but I prefer to use the command line tool pstoedit to make the conversion.
Inkscape's save as dxf dialog box

Inkskcape uses the same tool so if you run the command line tool without parameters you will have the same result. But the command line tool is preferable because you can use parameters to change the result.
You can run the command pstoedit -help to view a complete list of options  and available parameters  of this little program.
  Converting pdf to dxf with pstoedit step-by-step guide
  1. Open a terminal in the directory that contains the file you want to convert. You can use nautilus-open-terminal or use the cd command to do that.
  2. Run the command pstoedit -f dxf filename.pdf filename.dxf to make the conversion. Where filename is the name of the pdf that you want to convert. Of course you can use a different name for the dxf file but I prefer to use the same.
  3. Alternatively you can run pstoedit -f dxf_s filename.pdf. This will make a dxf file that contains splines and lines instead of polylines. In some drawings this command will give better results.

The output dxf file opened with Bricscad

Problems, troubleshooting and a very strange bug.
Converting a pdf file to dxf gives you the opportunity to change drawing's entities but the conversion isn't always the best way to work. If it is possible to have access to the original CAD file is much more preferable. Some issues are:
  • All the entities (even arcs,circles,hatches,dimensions and dimension texts) are polylines or splines and lines (See the screenshot above).
  • The converted file doesn't contain any layers. There is a parameter on pstoedit to match colors with layers but didn't worked for me. However if you work on DraftSight/ARES CE you can use the smart select tool to match easily entities with the same color to layers.
  • The pdf file probably is scaled. So you have to re-scale the whole drawing to get it in the original size.
  • If your pdf file contains a very complex drawing, the output dxf file may be too big.
  • At last I want to mention a very strange bug. If you use the first command and then open the dxf with all the programs that use ODA's libraries (ARES CE,Bricscad,DraftSight even TeighaViewer) all the polylines are duplicated. But if you open it with Librecad the file is OK. If you save the file from Librecad without any changes all the above programs open the file correctly. Notice that when you open Librecad's files with ARES CE/DraftSight snap is enabled, so use F9 to disable it and with Bricscad the grid is enabled so you have to disable it. Notice also that you have to use the latest version of Librecad and not the version which is in the Ubuntu's 11.04 repositories because that version doesn't open the dxf files properly.
The strange bug as shown in TeighaViewer

With pstoedit you can also convert .ps and .svg files to .dxf

No comments:

Post a Comment