Building a Deterministic DXF Comparison Engine in One Day
How do you compare two versions of an engineering drawing when one has been translated, rotated, or just has slightly different coordinate precision? This is the core problem in cad-dxf-agent. The ...

Source: DEV Community
How do you compare two versions of an engineering drawing when one has been translated, rotated, or just has slightly different coordinate precision? This is the core problem in cad-dxf-agent. The AI edit pipeline produces a modified DXF file, but you need to tell the user exactly what changed — which entities moved, which were added, which were deleted. And you need to do it deterministically, with confidence scores, even when floating-point noise makes coordinates drift by 0.0001 inches. I shipped the complete solution in four PRs across one day. Here's how each layer builds on the last. E1: Canonical Model + Stable Entity IDs The first problem is identity. DXF files don't have stable entity IDs — handles can change between saves, and there's no built-in concept of "this LINE in file A is the same LINE in file B." I audited every entity identity path and found six gaps: no stable IDs, no disambiguation, no coordinate normalization, no quantization, no spatial binning, no deterministi