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
Maintainers usually reply within 3 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 85/100
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
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
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from DomCR/ACadSharp
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 3 days
-
DWG writer: text styles get the text-style table as their xref block handlePossibly taken @menes97 claimed this 4 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 81/100
Maintainers usually reply within 3 days
-
Difficulty 1/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 3 days
-
DwgWriter writes a null shape-file handle for SHAPE entities (WriteShapes = true)Possibly taken @menes97 claimed this 4 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 3 days
-
DwgReader reads a color-book entity's Color as ByBlock instead of the book's colorPossibly taken @menes97 claimed this 4 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 3 days
Similar issues
-
hand-to-AI
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
CactuseSecurity/firewall-orchestrator#5803 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
bug python
Difficulty 1/5 Under an hour Newbie friendliness 88/100
ilia-sokolov/OfficeAgent.NET#89 ·
Maintainers usually reply within 13 days