Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two “72” of Hatch.BoundaryPath.Polyline are generated. #542

Closed
woodbook666 opened this issue Jan 24, 2025 · 3 comments · Fixed by #543
Closed

Two “72” of Hatch.BoundaryPath.Polyline are generated. #542

woodbook666 opened this issue Jan 24, 2025 · 3 comments · Fixed by #543
Labels
bug Something isn't working

Comments

@woodbook666
Copy link

Hello. Please excuse my poor English.
I have encountered a situation where the DWG output is normal and the DXF output has an error when I open the output file, even though they are the same code.
I tried the following sample code and found out that the cause is that when I output a Hatch with Polyline as Path, it outputs two “72” (if I delete one “72”, it opens normally).
Is this a problem with the way I wrote the code?
I would appreciate it if you could check.

CadDocument doc = new CadDocument(ACadVersion.AC1032);
var modelSpace = doc.ModelSpace;

string blockName = Guid.NewGuid().ToString();
var block = new Block(new(blockName));
var blockRecord = new BlockRecord(new(blockName));
var insert = new Insert(blockRecord);
modelSpace.Entities.Add(insert);

var hatch = new Hatch()
{
    Pattern = HatchPattern.Solid,
    Color = new ACadSharp.Color(0, 0, 0),
    IsAssociative = false,
    IsSolid = true,
    PatternType = HatchPatternType.SolidFill,
    IsInvisible = false,
    Style = HatchStyleType.Normal,
};

var path = new Hatch.BoundaryPath
{
    Flags = BoundaryPathFlags.External,
};

path.Edges.Add(new Hatch.BoundaryPath.Polyline()
{
    Vertices = [new(0, 0, 0), new(0, 5, 0), new(5, 5, 0), new(5, 0, 0)],
    IsClosed = true,
});
hatch.Paths.Add(path);

blockRecord.Entities.Add(hatch);

using (DxfWriter writer = new DxfWriter("C:\\testdata\\test.dxf", doc, false))
{
    writer.Write();
    writer.Dispose();
}

Image

@woodbook666 woodbook666 added the bug Something isn't working label Jan 24, 2025
@DomCR
Copy link
Owner

DomCR commented Jan 25, 2025

Hi @woodbook666,

Your code is correct, there is a bug in the DxfWriter, I'll open a branch to fix it.

Let me know if you are using the repo or the package so I can release an update.

Thanks for the report!

@DomCR DomCR linked a pull request Jan 25, 2025 that will close this issue
@woodbook666
Copy link
Author

I am using the package installed via NuGet.
Thanks for the quick response.

@DomCR
Copy link
Owner

DomCR commented Jan 27, 2025

1.0.8 Released!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants