cart: empty [ Login ]

ACAD_PROXY_ENTITY gets cropped after converting to PDF

1 
Emilsson
5/31/2018 7:16 AM
Hi! When converting the attached DWG file using the code below the resulting PDF file has a cropped shape. The shape in question is a proxy object; maybe that has something to do with it? I've attached the DWG, a screenshot from AutoCad, and the PDF. As you can see in the PDF, the right arc of the elongated circle is missing. /Tomas Emilsson
C# Code:
namespace TestCadlib { using System; using System.Drawing.Printing; using System.IO; using WW.Cad.Base; using WW.Cad.Drawing; using WW.Cad.IO; using WW.Cad.Model; using WW.Math; using Color = System.Drawing.Color; class Program { static void Main(string[] args) { const float Margin = 0f; string dwgPath = @"C:\Temp\Test.dwg"; using (FileStream inStream = new FileStream(dwgPath, FileMode.Open)) using (FileStream outStream = new FileStream(dwgPath + ".pdf", FileMode.Create)) { DwgReader reader = new DwgReader(inStream) { LoadUnknownObjects = true }; DxfModel model = reader.Read(); PdfExporter pdfExporter = new PdfExporter(outStream) { EmbedFonts = false, Author = String.Empty, PackContent = false }; GraphicsConfig graphicsConfig = new GraphicsConfig(Color.White) { DefaultLineWeight = 0, FixedForegroundColor = Color.Black }; BoundsCalculator boundsCalculator = new BoundsCalculator(); boundsCalculator.GetBounds(model); Bounds3D bounds = boundsCalculator.Bounds; PaperSize paperSize = PaperSizes.GetPaperSize(PaperKind.A4); // "Stretch" paper if necessary paperSize.Width = Math.Max(paperSize.Width, (int)(bounds.Delta.X / bounds.Delta.Y * paperSize.Height)); // Length in inches (PaperSize.Width is in 100ths of an inch). float pageWidth = paperSize.Width / 100f; float pageHeight = paperSize.Height / 100f; // Scale and transform to fit PDF page double scaling; Matrix4D to2DTransform = DxfUtil.GetScaleTransform( bounds.Corner1, bounds.Corner2, new Point3D(bounds.Center.X, bounds.Corner2.Y, 0d), new Point3D(new Vector3D(Margin, Margin, 0d) * PdfExporter.InchToPixel), new Point3D(new Vector3D(pageWidth - Margin, pageHeight - Margin, 0d) * PdfExporter.InchToPixel), new Point3D(new Vector3D(pageWidth / 2d, pageHeight - Margin, 0d) * PdfExporter.InchToPixel), out scaling); pdfExporter.DrawPage(model, graphicsConfig, to2DTransform, scaling, null, null, paperSize); pdfExporter.EndDocument(); } } } }
Autocad.png
Wout
6/5/2018 12:05 PM
Hi Tomas, The problem has been fixed, please download the latest CadLib 4.0 version. There was a problem with proxy graphics Arc3Point rendering. Thank you for the report! - Wout
Emilsson
6/8/2018 9:03 AM
When I updated to the newest version (4.0.38.69) I found that the DxfModel.GlobalShxLookupDirectories/ClearShxLookupDirectories methods are missing. There is also a new property GlobalShxFontFileLoaders. Am I supposed to use this property instead?
Wout
6/8/2018 9:12 AM
Yes, they serve the same purpose, but allow more flexibility loading fonts from locations other than filesystems. For loading from directory you can use the FontFromDirectoryFileLoader implementation. - Wout
Emilsson
6/8/2018 9:15 AM
Ok, that makes sense. Thanks! /Tomas
1