This project has moved. For the latest updates, please go here.

Zoom to extents after loading dxf file

May 29 at 9:14 AM
Hi.

I wanted to create a dxf file and it works very well. But after loading, my drawing seems empty. After a "fit zoom to whole content" I see my drawing. Can anybody help me? What's wrong?

Here's my code sample:
DxfDocument dxfDoc = new DxfDocument();
            dxfDoc.DrawingVariables.AcadVer = DxfVersion.AutoCad2010;
            
            var p1 = new PolylineVertex(250, 20, 17);
            var p2 = new PolylineVertex(250, 50, 17);
            var p3 = new PolylineVertex(350, 50, 17);
            var p4 = new PolylineVertex(350, 10, 17);

            var p11 = new PolylineVertex(250, 10, 20);
            var p12 = new PolylineVertex(250, 50, 20);
            var p13 = new PolylineVertex(350, 50, 20);
            var p14 = new PolylineVertex(350, 10, 20);

            Polyline poly = new Polyline()
            {
                Layer = new Layer("Reference line")
                {
                    Color = AciColor.Green
                },
                Color = AciColor.Green,
                IsClosed = true
            };
            
            poly.Vertexes.Add(p1);
            poly.Vertexes.Add(p2);
            poly.Vertexes.Add(p3);
            poly.Vertexes.Add(p4);

            dxfDoc.AddEntity(poly);

            poly = new Polyline()
            {
                Layer = new Layer("Reference line")
                {
                    Color = AciColor.Green
                },
                IsClosed = true
            };

            poly.Vertexes.Add(p11);
            poly.Vertexes.Add(p12);
            poly.Vertexes.Add(p13);
            poly.Vertexes.Add(p14);

            dxfDoc.AddEntity(poly);
            
            dxfDoc.VPorts.FirstOrDefault().ViewCenter = new Vector2(300, 30);
            dxfDoc.VPorts.FirstOrDefault().ViewHeight = 100;

            return dxfDoc.Save(@"C:\temp\test1.dxf");
Thanks
Hermann
Coordinator
Jun 1 at 5:59 PM
There is nothing wrong, you cannot set the initial view of the drawing, not implemented. This is a purely cosmetic issue.

Daniel