Blog · DXF · 29 Sep 2026 · 3 min read
Can AI read DXF files? Yes, with one step in between
A DXF is plain text, but an AI model should not read it raw. It writes a small script that reads the drawing for it. What that looks like, and how to set it up in four steps.
Short answer: yes. A DXF file is plain text, so an AI model can open it. But pasting a DXF into a chat is the wrong way to do it, and the answers you get back that way are often guesses.
The reliable way has one step in between: the AI writes a small script that reads the drawing, runs it, and answers from the result.
Why not paste the DXF into a chat
- They are long. A single part can be thousands of lines of group codes and numbers. A full drawing sheet is much more.
- The geometry is not where you expect it. Many entities live inside blocks, and dimensions store their visible text in a separate block.
- The model estimates instead of measuring. Asked "how many holes are there?", it may count what it saw in part of the file.
A script does not estimate. It reads every entity, every time.
How to set it up
- Install Python on the computer where your drawings are.
- Install ezdxf, an open source Python library for reading and writing DXF files:
pip install ezdxf - Use an AI agent that can run commands on your computer. We use Claude Code. A chat window that cannot run code will only describe the script, not execute it.
- Ask in plain words: "Open part.dxf and tell me how many circles are on the CUT layer and the overall size of the part."
What the agent writes
For a question like the one above, the script is short:
import ezdxf
from ezdxf import bbox
doc = ezdxf.readfile("part.dxf")
msp = doc.modelspace()
circles = msp.query('CIRCLE[layer=="CUT"]')
print(len(circles), "circles on layer CUT")
box = bbox.extents(msp.query('*[layer=="CUT"]')) # the part only, not its dimensions
print("overall size:", round(box.size.x, 1), "x", round(box.size.y, 1))
The agent runs it, reads the output and answers with the numbers it printed. If the answer looks wrong, you can ask to see the script and the output.
What you can ask once it is set up
- How many holes, and of which diameter, on each part.
- The overall size of every part in a folder of DXF files.
- Which files use a layer name your cutting machine does not expect.
- Whether two versions of a drawing differ, and where.
- Every text on the drawing, for example to check part codes against a parts list.
Three traps to know about
Units. A DXF declares its units in the header, and not every file declares them correctly. Ask the agent to print doc.units before trusting any size.
Blocks. Geometry inside a block is not in the model space list until you expand it. The script should look inside INSERT entities with virtual_entities(), or it will miss parts of the drawing.
Dimensions. A dimension often stores <> instead of its value. The real number is somewhere else. We wrote a separate guide on where to find it.
A count is not a check
The most useful habit: when the result matters, look at the drawing as well as the numbers. ezdxf can render a DXF to an image, and an agent can show it to you. A script that prints "120 parts OK" can still be reading the wrong file.
Do and don't
Do
- Let the agent write and run a script; answer from its output.
- Print
doc.unitsbefore trusting sizes. - Expand blocks with
virtual_entities(). - Render the drawing and look at it when the answer matters.
Don't
- Don't paste a DXF into a chat.
- Don't trust
ezdxf.bboxfor text width: measure text with the font. - Don't take ezdxf's audit as proof a file opens in CAD.
Related: render a DXF to PNG for an AI agent, merge DXF files with ezdxf.
If you want this set up on your own drawings, or want the work done for you, send us a file.