DwgReader leaves Leader.TextWidth/TextHeight at 0 for text-annotated LEADERs — DXF group 41 comes out 0.0 and downstream consumers drop the hook line

Open Beginner friendly
#1,180 3 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 3 days

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
85/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
csharp
Domain
tooling

Research direction

Start in the DwgReader implementation where LEADER entities are parsed; locate the section that reads annotation-related data and add extraction of the text width/height (DXF group 41 equivalent) from the DWG stream. Compare with reference converters to identify the correct DWG handle or data offset. Run the provided repro script against a DWG with annotated leaders to confirm the fix, and check for existing tests under the test/models directory that cover LEADER entities.

Written by the indexing model from the issue text.

Description

bug

Summary

DwgReader leaves Leader.TextWidth and Leader.TextHeight at 0 for every LEADER entity, including annotated ones (CreationType == CreatedWithTextAnnotation, AssociatedAnnotation != null), even though the annotation width is present in the source DWG — reference converters read the same entities (matched by handle) and emit DXF group 41 values like 685.7142857142858 / 2571.428571428572, while ACadSharp emits 41 = 0.0.

This is a reader gap, not a writer gap: the value is already 0 in the object model immediately after DwgReader.Read(), so it cannot be recovered by post-processing the written DXF.

Repro (3.6.51)

Needs a DWG containing text-annotated LEADERs (any AutoCAD-authored drawing with leader callouts reproduces it; I can provide a trimmed sample on request).

using ACadSharp.Entities;
using ACadSharp.IO;

var doc = new DwgReader(args[0]).Read();

int total = 0, annotated = 0, withWidth = 0;
foreach (var br in doc.BlockRecords)
    foreach (var e in br.Entities)
    {
        if (e is not Leader ld) continue;
        total++;
        bool isAnnotated = ld.AssociatedAnnotation is not null;
        if (isAnnotated) annotated++;
        if (ld.TextWidth != 0) withWidth++;
        if (isAnnotated && annotated <= 5)
            Console.WriteLine($"handle={ld.Handle:X} CreationType={ld.CreationType} " +
                $"TextWidth={ld.TextWidth} TextHeight={ld.TextHeight} " +
                $"AssociatedAnnotation={ld.AssociatedAnnotation!.GetType().Name}");
    }

Console.WriteLine($"LEADER total={total} annotated={annotated} withNonZeroTextWidth={withWidth}");

Observed on a real AutoCAD-authored file:

LEADER total=23 annotated=19 withNonZeroTextWidth=0
REPRO: every annotated LEADER has TextWidth == 0

Impact

DXF consumers use group 41 to decide whether to draw the LEADER hook line (the short horizontal landing segment under the annotation text) — e.g. ezdxf (ezdxf/render/leader.py) requires text_width > 0. With 41 = 0 the hook line is never emitted, so it disappears from any rendering of the converted file. Measured on the file above: 19 of 23 leaders lose their hook line; leader segments drop 69 → 50 and total leader line length drops 131,877.9 → 58,935.0 drawing units versus a reference conversion of the same DWG.

Found in the same DWG→DXF fidelity audit as #1179.

Environment: ACadSharp 3.6.51 (NuGet), .NET 10, Linux x64.

Dominant language
C#
Stars
873
Forks
223
Avg merge
1d 15h
Merged PRs (30d)
28

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from DomCR/ACadSharp

All issues in DomCR/ACadSharp

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.