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

A script does not estimate. It reads every entity, every time.

How to set it up

  1. Install Python on the computer where your drawings are.
  2. Install ezdxf, an open source Python library for reading and writing DXF files: pip install ezdxf
  3. 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.
  4. 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

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

Don't

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.