Code covered by the BSD License  

Highlights from

4.8 | 6 ratings Rate this file 127 Downloads (last 30 days) File Size: 693 KB File ID: #33884 Version: 1.2




22 Nov 2011 (Updated )

DXFLib is a library written in MATLAB that allows to create simple AutoCAD DXF files.

| Watch this File

File Information

DXFLib is a library written in MATLAB that allows to create simple AutoCAD DXF files. Autocad DXF is a popular file format that can be interpreted in many CAD-related applications. AutoCAD DXF can be also converted to a PDF file containing 3D geometry using any 3D printer driver.
The DXFLib handles DXF layers and ACI Colors (RGB colors are automatically converted to their ACI counterparts). It is capable of exporting point, polylines, polysurfaces, text, various 3D primitives and 2D markers.


Just unpack zipped m-files to your working directory or create a separate directory and add its location to MATLAB path. All m-files are located in to root directory. The /examples directory contains DXF files which are generated by dxf_test.m script. Some DXF files are converted to 3D PDF files using Bentley View 3D printer driver.


The easiest way to learn how to create DXF files using DXFLib is to simply run the dxf_test.m script and then open it in MATLAB editor and compare the generated DXF files with the code inside the script. Obviously, you'll need any DXF viewer that is capable to handle 3D content. I recommend
to use free Bentley View software ( The
advantage of using Bentley View is that this software is capable to PRINT 3D PDF
files (some DXF files in /exaples subdirectory were converted using this 3D PDF printer driver). More examples and a short tutorial is available at:

DXFLib page:

MATLAB release MATLAB 7.8 (R2009a)
MATLAB Search Path
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (10)
08 Feb 2016 Sam Dehdar

Excellent Library, very good work. Do you by any chance have anything that would be able to create a table in DXF format?

I've tried to do it, but I keep running into a wall! And how do you distinguish between what is optional to have in a DXF and what is not? Maybe you could point me towards some proper literature :)?

04 Jan 2016 Nanofabulous

Thanks for this library, its very useful. Is there a way to ensure that the polylines are closed? For example (and I don't know if this is the best way to do this) I am writing a series of rotated rectangles based on center points and angles. I use the polyline function but all the resulting rectangles are open. Thanks for the help!

11 Sep 2015 Lucas Solo

Great library, very useful! Thanks

16 Dec 2014 Lars Wadsö

Nice toolbox, but I have a problem. I want to make dxf-files for laser cutting and used dxf_polyline to write X-Y curves/shapes (setting Z to 0) to a dxf-file. When I open the file in 2D with AutoCAD or DraftSight the curves only show up as points (no lines). How can I make 2D lines/curves?

Comment only
16 Dec 2014 Grzegorz Kwiatek

Hi Lars, thank you for your feedback. The website has been updated to:

Comment only
15 Dec 2014 Lars Wadsö

The link to the tutorial ( does not work. Is there an alternative link?

Comment only
31 Jul 2014 Alexei Adalev

Very useful, thanks a lot!

13 Apr 2013 Grzegorz Kwiatek

Varun AV, The circles will be incorporated in the next version of DXFLib.

Comment only
25 Dec 2012 Varun AV

The library is useful, however, it could include circles too.


12 Oct 2012 Grzegorz  
22 Nov 2011 1.1

Changes in the description.

16 Dec 2014 1.2

Changed DXFLib website address

Contact us