Free, open-source file converter. Convert 263 formats offline by drag & drop — images, PDF, Word, Excel, PowerPoint, HWP/HWPX, video, audio, e-books and archives. No upload, no Office needed.
C# audio-converteravaloniabatch-conversionconvertercsharpdocument-converterdocx-to-pdfdotnetdrag-and-dropfile-conversionfile-converterheic-converterhwphwpximage-converterlinuxmacospdf-convertervideo-converterwindows
CAD layouts: empty model space does not show through the viewports
KnifeLemon80ea6766dffc
diff --git a/src/Filee.Engines/Cad/CadConverter.cs b/src/Filee.Engines/Cad/CadConverter.csindex 517a7f05..2b58eadd 100644--- a/src/Filee.Engines/Cad/CadConverter.cs+++ b/src/Filee.Engines/Cad/CadConverter.cs@@ -86,8 +86,11 @@ public sealed class CadConverter(ILogger? logger = null) : IConverter, IImageTracase "pdf":using (var stream = File.Create(output)){+ // With empty model space the scene is the active layout's paper space, which must not show+ // through the viewports.if (sheets.Count > 0)- CadRenderer.WritePdf(sheets, scene, step.Preset.Pdf, Path.GetFileNameWithoutExtension(step.InputPath), stream);+ CadRenderer.WritePdf(sheets, scene.Space == "model" ? scene : new CadScene(), step.Preset.Pdf,+ Path.GetFileNameWithoutExtension(step.InputPath), stream);elseCadRenderer.WritePdf(scene, step.Preset.Pdf, Path.GetFileNameWithoutExtension(step.InputPath), stream);}diff --git a/tests/Filee.Engines.Tests/CadLayoutTests.cs b/tests/Filee.Engines.Tests/CadLayoutTests.csindex 65c1ec60..8da4a63b 100644--- a/tests/Filee.Engines.Tests/CadLayoutTests.cs+++ b/tests/Filee.Engines.Tests/CadLayoutTests.cs@@ -127,6 +127,36 @@ public class CadLayoutTests(EngineFixture fx) : IClassFixture<EngineFixture>Assert.Equal(1, document.PageCount);}+ [Fact]+ public async Task Empty_model_space_shows_nothing_through_the_viewports()+ {+ // Model space is empty, so the one-picture scene is the active layout's paper space; that must not be drawn+ // again inside the viewport. The blue border runs along the sheet edges, and a view of model space around+ // (50, 50) would put its corner in the middle of the frame.+ var doc = new CadDocument();+ var border = new Layer("Border") { Color = CadBuilder.Visible };+ doc.Layers.Add(border);+ doc.PaperSpace.Entities.Add(new LwPolyline(new LwPolyline.Vertex(0, 0), new LwPolyline.Vertex(420, 0),+ new LwPolyline.Vertex(420, 297), new LwPolyline.Vertex(0, 297))+ { IsClosed = true, Layer = border });+ doc.PaperSpace.Entities.Add(new Viewport+ {+ Center = new XYZ(210, 148.5, 0),+ Width = 200,+ Height = 150,+ ViewCenter = new XY(50, 50),+ ViewHeight = 150,+ });+ var dxf = CadBuilder.SaveDxf(doc, fx.NewFolder(), "paper.dxf");++ var job = await fx.ConvertAsync([dxf], new Preset { TargetFormat = "pdf" });++ Assert.True(job.State == JobState.Completed, string.Join("; ", job.Files.Select(f => $"{f.ErrorKey} {f.ErrorDetail}")));+ var pdf = job.Outputs.Single();+ Assert.True(Blue(pdf, 0, 0, 0, 1, 1) > 20, "the border is on the page");+ Assert.Equal(0, Blue(pdf, 0, 0.27, 0.26, 0.73, 0.74));+ }+[Fact]public async Task Images_and_svg_stay_one_picture_of_model_space(){