cart: empty [ Login ]

Drawing file is not valid error

1 
Sachin Tripathi
10/4/2019 10:56 AM
Hi, I'm getting the "Drawing file is not valid" error. See code below:
C# Code:
public static void DrawMultiplePages() { double xCor = 0; double yCor = 0; int pageWidth = 48; DxfModel model = new DxfModel(); for (int index = 1; index <= 2; index++) { DrawPage(model, xCor, yCor, $"Page ({index})", index); xCor = xCor + pageWidth + 10; } DxfWriter.Write("D:\\HCS\\Documents\\Output\\ResultModel.dwg", model, false); } public static void DrawPage(DxfModel model, double xCor, double yCor, string zoneName, int index) { double heigth = 36; double width = 48; DxfBlock resultBlock = new DxfBlock($"Block_{index}"); model.Blocks.Add(resultBlock); DxfVertex2D[] pole = new DxfVertex2D[] { new DxfVertex2D(xCor, yCor), new DxfVertex2D(xCor + width, yCor), new DxfVertex2D(xCor + width, yCor + heigth), new DxfVertex2D(xCor, yCor + heigth) }; // 2D spline. DxfPolyline2D polyline2D = new DxfPolyline2D(pole); polyline2D.Closed = true; DxfText dxfText = new DxfText(zoneName, new Point3D(xCor + (width) / 2 - 4, yCor + heigth + 2, 0), 2); dxfText.Thickness = 10D; resultBlock.Entities.Add((DxfEntity)polyline2D); resultBlock.Entities.Add((DxfEntity)dxfText); model.Entities.Add(new DxfInsert(resultBlock)); }
Your help is much appreciated! -Sachin
Error.png
Wout
10/4/2019 11:16 AM
Use the DwgWriter instead of the DxfWriter if you are writing a DWG file. - Wout
Sachin Tripathi
10/4/2019 11:21 AM
Oh great. Thank you!
1