Generated DWG displays as black screen until AutoCAD Command is run

Open
#1,102 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 3 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
csharp
Domain
tooling

Research direction

Start by reproducing the issue with the C# example in the report, which writes a DWG using DwgWriter, then inspect how the writer handles the drawing view or extents. Compare the freshly generated file with the same file after running Zoom Extents in AutoCAD. Done means the drawing is visible and the coordinates respond normally on opening, without running that command.

Written by the indexing model from the issue text.

Description

bug

Describe the bug
When generating a DWG File, the file generated is displayed as a black screen in AutoCAD. The coordinates in AutoCAD do not change when moving the mouse.

When I run zoom extents in AutoCAD, the correct image and blocks display. It displays properly at this point.

PAPERSPACE

To Reproduce

            BlockRecord result = new("Test BlockRecord");

            result.Entities.Add(new Circle() {Center = new(5, 5, 0)});
            result.Entities.Add(new TextEntity() {Value = "Test Text"});

            CadDocument doc = new();

            doc.BlockRecords.Add(result);

            Insert insert = new(result);
            insert.InsertPoint = new(20, 20, 0);

            doc.BlockRecords[BlockRecord.PaperSpaceName].Entities.Add(insert);

            using (var file = File.Create(@$"{yourFileDirectory}\TestText.dwg"))
            using (var dwgWriter = new DwgWriter(file, doc))
            {
                dwgWriter.OnNotification += (o, args) => Debug.WriteLine(args.Message);
                dwgWriter.Write();
            }

Expected behavior
Generated frontsheet should not need AutoCAD command, Zoom Extents, to run to have a dwg be displayed.

Screenshots
Freshly generated (3.4.29)
Image

Freshly generated (3.6.12)

Image

After zoom extents

Image

Additional context

Bug first appeared after migrating from 3.4.24 to 3.4.29.
Everything displays properly after zoom extents command.
On freshly generated DWG, coordinates in AutoCAD remain 0,0,0 no matter where mouse is moved. After command run, the coordinates change. Not sure how helpful this information is.

Release needed

  • Yes, using the Nuget package.
  • No, using the github repo.
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.