Skip to content

Incorrect aligned dimension extension lines and measurment text for slightly non-vertical segments #1300

@necto

Description

@necto

For certain segments, rendering an aligned dimension results in incorrect extension lines and wrong measurement text. Depending on the point coordinates, it might be correct or wrong, while the dimension.get_measurement() returns the correct value.

Here is the reproducer example:

import ezdxf
print(f"Using ezdxf version: {ezdxf.__version__}")

points = [
    (250235.3373553778, 99368),
    (250235.3373553779, 99412),
]

output_filename = "polyline_example.dxf"

doc = ezdxf.new()
doc.modelspace().add_lwpolyline(points)

p1, p2 = points[0], points[1]
doc.modelspace().add_aligned_dim(p1, p2, distance=20).render()

print(f"Polyline points: {points}")
dim = list(doc.modelspace().query("DIMENSION"))[0]
print(f"Dimension text: {dim.dxf.text}")
print(f"Dimension measurement: {dim.get_measurement()}")
for e in dim.virtual_entities():
    if e.dxftype() == "MTEXT":
        print(f"MTEXT text: {e.dxf.text}")

doc.saveas(output_filename)
print(f"DXF file '{output_filename}' created successfully!")

Note that the distance between the points is ~44 units.

I use python version 3.12.9

Output:

Using ezdxf version: 1.4.2
Polyline points: [(250235.3373553778, 99368), (250235.3373553779, 99412)]
Dimension text: <>
Dimension measurement: 44.0
MTEXT text: 32
DXF file 'polyline_example.dxf' created successfully!

Image

If I change the numeric values ever so slightly, I get the expected parallel lines and correct measurement text:

Using ezdxf version: 1.4.2
Polyline points: [(250235.337355377, 99368), (250235.337355377, 99412)]
Dimension text: <>
Dimension measurement: 44.0
MTEXT text: 44
DXF file 'polyline_example.dxf' created successfully!

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions