Blog · DXF · 1 Oct 2026 · 3 min read
Merging DXF files puts sections and weld symbols in the wrong place? Block names collide
Combine several DXF sheets into one and some sections, details or weld symbols show content from another sheet. No error, and every count says OK. Inventor numbers its blocks from zero on every sheet. How an AI agent detects the collision by content and remaps it.
Short answer: Inventor names the blocks of sections, details and weld symbols 2dTransSection0, 2dDetail0, Welding Symbol Identifier1, and starts again from zero on every sheet. When you merge sheets into one DXF, two different blocks share a name. If the merge script keeps the first and skips the rest, every later sheet draws the first sheet's content. Compare blocks by content, give colliding ones a name of their own, and remap the INSERTs.
The symptom
After merging the client's original sheets into one file, the person who opened it said: "weld symbols and sections are not in the right place." The merge script had ended with RESULT: ALL OK.
The cause, measured
- 505 blocks across the sheets.
- 16 names appeared in more than one sheet, with different content.
- The merge function skipped names already present.
So sheet 3's 2dTransSection0 drew sheet 1's section.
Why no check saw it
An INSERT pointing to the wrong block is identical, by count, to one pointing to the right block. Same number of entities, same number of blocks, same layers. Counts cannot catch it. Only two things do: a check of where each insert draws, and an image.
The fix: compare by content, remap on collision
if name in doc_out.blocks:
if block_signature(doc_out.blocks.get(name)) == block_signature(src):
continue # identical: reuse it
dst_name = f"{name}_{suffix}" # collides: give it its own name
remap[name] = dst_name
After copying, every INSERT from that sheet whose block was remapped gets the new name. The signature is built from the block's entities (types and geometry), so two blocks with the same content are reused and two with different content are kept apart.
The check that would have caught it: does every INSERT draw inside the frame of its own sheet? Compute the extents of each insert and test them against the sheet's frame.
Two shortcuts that make it worse
Exploding the sheets. The collision disappears, and so does the structure: weld symbols become loose lines and texts. The problem is not that blocks exist. It is that two have the same name.
Renaming every block. Dimension styles refer to arrowhead blocks by name (_Closed, Filled-1, DatumFilled45). Rename them all and the references break. ezdxf fails when writing, and one file shrank from 675,342 to 40,889 bytes.
Rename only the blocks that collide.
Other block traps when merging with ezdxf
| Trap | Effect | Fix |
|---|---|---|
entity.copy() on an INSERT |
Copies the reference, not the block definition. BricsCAD reports Empty Record name; ezdxf's audit says 0 errors |
Copy the definitions too. Count AcDbBlockReference against BLOCK in the raw text |
add_foreign_entity with DIMENSION or INSERT |
They vanish without an error | Copy them with their blocks, as above |
*D dimension blocks |
Not inserts: the DIMENSION refers to them through geometry, in absolute coordinates |
Move them with their dimension, see merging DXF files with ezdxf |
The rule behind it
In one DXF a name means one thing. Dimension styles, text styles and blocks all fail the same way, and "if the name exists, skip it" causes all three. The style version of this bug cost us a month: why dimensions change size when you paste DXF drawings.
Do and don't
Do
- Compare blocks by content before reusing a name.
- Rename only the colliding blocks, with a suffix from the sheet.
- Check that each insert draws inside its own sheet.
- Look at the merged file as an image.
Don't
- Don't skip a block because its name exists.
- Don't explode sheets to avoid collisions.
- Don't rename every block.
- Don't trust ezdxf's audit as proof that the file opens correctly in CAD.
Questions people ask
Which blocks collide most? In Inventor exports: section views, detail views and weld symbols, because Inventor numbers them from zero on each sheet.
Can an AI agent do this merge reliably? Yes, with the content check and the frame check. Without them it will report success on a wrong file.