Using libDXF library

The use of CAD applications is enormous and so has been the need for standardization. An initiative made by Autodesk back in 1982 to provide a representation of the content in the drawing resulted in the creation of DXF (Drawing Exchange Format).

libDXF is a library to read and write DXF files. The library is used to parse the content stored in DXF files to create drawings when opened in a CAD software. Reading and writing of these files via this library needs an understanding of the structure of DXF.

I worked on a task to create a DXF drawing from a simple input file given by the user. The input file looks like:

wall(l=100,h=30,bx=10,by=10)
wall(l=10,h=50,bx=0,by=0)
flange(r=20,cx=50,cy=100)

The next step I performed is splitting of this input file via the separators: "(", ")", ",", "=".

Saving everything in an output file which looks like:
wall
l
100
h
30
bx
10
by
10
for one wall and similarly for the other entities.

Further in the functions defining the creation of entities, only the numeric numbers are needed as arguments. Creating a regular expression to extract the numbers from the output file and saving the numbers in a vector, the entities are saved to a DXF file. Figure below shows a drawing I created via this procedure:

Screenshot from 2016-02-22 10:27:17

The complete work can be referred at: https://github.com/kamalpreetgrewal/textToDrawing

Leave a Reply

Follow

Get notified with the latest posts

Plugin Supporter WordPress Post Navigation
%d bloggers like this: