0% found this document useful (0 votes)
85 views11 pages

15-294 Rapid Prototyping Technologies: DXF Files: Dave Touretzky Computer Science Carnegie Mellon University

This document discusses the DXF file format used for transferring CAD drawings between programs. It describes the different sections and elements of a DXF file, including entities, blocks, and the tagged data format. It also mentions some Python libraries for working with DXF files, including dxfwrite for generating DXF files and dxfgrabber for reading them. Basic examples are provided for creating lines and arcs in a DXF file using dxfwrite and displaying graphics in Python using Tkinter.

Uploaded by

Lieu Dinh Phung
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
85 views11 pages

15-294 Rapid Prototyping Technologies: DXF Files: Dave Touretzky Computer Science Carnegie Mellon University

This document discusses the DXF file format used for transferring CAD drawings between programs. It describes the different sections and elements of a DXF file, including entities, blocks, and the tagged data format. It also mentions some Python libraries for working with DXF files, including dxfwrite for generating DXF files and dxfgrabber for reading them. Basic examples are provided for creating lines and arcs in a DXF file using dxfwrite and displaying graphics in Python using Tkinter.

Uploaded by

Lieu Dinh Phung
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

15-294 Rapid Prototyping

Technologies:

DXF Files

Dave Touretzky
Computer Science
Carnegie Mellon University

1
The DXF File Format
● Drawing Interchange Format
– or –
Drawing Exchange Format
● Proprietary file format, not an ANSI standard.
● Developed by AutoDesk in 1982 to allow their
AutoCAD product to inter-operate with other
programs.
● Partial specification now publicly available on
AutoDesk's web site.
2
Types of DXF File
● ASCII (human readable) or binary.
● DXF version number:
– R14, R13, R12
– 2010, 2007-2009, 2004-2006

● Later versions add new features such as


complex curves and 3D shapes.
● When exporting to DXF for use with a laser
cutter, ASCII R2010 is a safe choice.
3
Sections of a DXF File
● HEADER – parameters such as units, min/max values
● CLASSES – application-specific data
● TABLES – line types, colors, layers, etc.
● BLOCKS – macros for repeating entities
● ENTITIES – where the lines and arcs are defined
● OBJECTS – data for non-graphical objects
● THUMBNAILIMAGE
● END OF FILE
4
Tagged Data Format
● Every element in a DXF file takes two lines:
– Integer “group code” indicating the type of item
– Value of the item (can be a number, string, etc.)
● Some common group codes:
0: Entity type (string)
2: Name of the entity (string)
9: DXF variable name in header section (string)
10, 20, 30: Primary X/Y/Z value (float)
11, 21, 31: Secondary X/Y/Z value (float)
40: radius 5
DXF File: One Line and One Arc
0 0
SECTION ARC

2 10
ENTITIES 60.0

0 20
75.0 Arc at (60.0,75.0),
LINE radius 25.0,
40 from 0 to 180 deg.
10
25.0
5.125
Line from 50
20 (5.125,7.625) to 0.0
7.625 (107.25,50.875)
51
11 180.0 Do not put any
107.25 blank lines in
0
21 the file.
ENDSEC
50.875
0 6
EOF
Python DXF Libraries
● Multiple DXF libraries exist for Python.

● dxfwrite is used in assignment #2:


– Sets up reasonable header values and tables.
– You can modify them if desired.
– Provides primitives to make entities.

● dxfgrabber reads a DXF file and returns a


Python structure with all the info.
7
Using dxfwrite
from dxfwrite import DXFEngine as dxf
drawing = dxf.drawing('mypiece.dxf')

drawing.add(
  dxf.line((5.125, 7.625),
           (107.25, 50.875),
           color=1))

drawing.save()

8
Graphics in Python
● Use Tkinter for simple on-screen graphics
● Create a Canvas widget, then add lines etc.
● Coordinates are in pixels; must be integers.
● Use mainloop() to have Tk render the canvas.

9
Drawing A Line With Tk
from Tkinter import *
master = Tk()
w = Canvas(master, width=800, height=800)
w.pack()

w.create_line(51, 77, 1070, 508,
              fill='red')

mainloop()
10
Future Project: Vector Optimizer
● Drawing programs output vectors in seemingly
random order.
● Laser cutting can go much faster if the vectors
are ordered so as to minimize head motion
with the laser off (not cutting = not useful).
● Many laser cutter drivers now include a vector
optimizer, sometimes with user controls.
● Rabbit Laser's optimizer can be improved.

11

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy