[dxf] fix reading Polyline

This commit is contained in:
Jan Petykiewicz 2026-03-30 20:22:40 -07:00
commit 9ede16df5d
2 changed files with 22 additions and 3 deletions

View file

@ -1,5 +1,6 @@
import io
import numpy
import ezdxf
from numpy.testing import assert_allclose
from pathlib import Path
@ -109,3 +110,20 @@ def test_dxf_manhattan_precision(tmp_path: Path):
target_name = next(k for k in read_top.refs if k.upper() == "SUB")
ref = read_top.refs[target_name][0]
assert isinstance(ref.repetition, Grid), "Grid should be preserved for 90-degree rotation"
def test_dxf_read_legacy_polyline() -> None:
doc = ezdxf.new()
msp = doc.modelspace()
msp.add_polyline2d([(0, 0), (10, 0), (10, 10)], dxfattribs={"layer": "legacy"}).close(True)
stream = io.StringIO()
doc.write(stream)
stream.seek(0)
read_lib, _ = dxf.read(stream)
top_pat = read_lib.get("Model") or list(read_lib.values())[0]
polys = [shape for shape in top_pat.shapes["legacy"] if isinstance(shape, Polygon)]
assert len(polys) == 1
assert_allclose(polys[0].vertices, [[0, 0], [10, 0], [10, 10]])