コード例 #1
0
ファイル: Program.cs プロジェクト: NTUST-PTL/PTL-Project
        private static void HatchTest4()
        {
            DxfDocument dxf = new DxfDocument(DxfVersion.AutoCad2010);

            LwPolyline poly = new LwPolyline();
            poly.Vertexes.Add(new LwPolylineVertex(-10, -10));
            poly.Vertexes.Add(new LwPolylineVertex(10, -10));
            poly.Vertexes.Add(new LwPolylineVertex(10, 10));
            poly.Vertexes.Add(new LwPolylineVertex(-10, 10));
            poly.IsClosed = true;

            List<HatchBoundaryPath> boundary = new List<HatchBoundaryPath>() { new HatchBoundaryPath(new List<EntityObject>()) }; ;
            //List<HatchBoundaryPath> boundary = new List<HatchBoundaryPath> {new HatchBoundaryPath(new List<Entity> {poly})};
            HatchGradientPattern pattern = new HatchGradientPattern(AciColor.Yellow, AciColor.Blue, HatchGradientPatternType.Linear);
            pattern.Origin = new Vector2(120, -365);
            Hatch hatch = new Hatch(pattern, boundary);
            dxf.AddEntity(hatch);
            dxf.AddEntity(hatch.CreateWCSBoundary());
            
            dxf.Save("HatchTest4.dxf");
            dxf = DxfDocument.Load("HatchTest4.dxf");
            dxf.Save("HatchTest4 copy.dxf");

        }
コード例 #2
0
ファイル: Program.cs プロジェクト: NTUST-PTL/PTL-Project
        private static void HatchTest1()
        {
            DxfDocument dxf = new DxfDocument();

            LwPolyline poly = new LwPolyline();
            poly.Vertexes.Add(new LwPolylineVertex(-10, -10));
            poly.Vertexes.Add(new LwPolylineVertex(10, -10));
            poly.Vertexes.Add(new LwPolylineVertex(10, 10));
            poly.Vertexes.Add(new LwPolylineVertex(-10, 10));
            poly.Vertexes[2].Bulge = 1;
            poly.IsClosed = true;

            LwPolyline poly2 = new LwPolyline();
            poly2.Vertexes.Add(new LwPolylineVertex(-5, -5));
            poly2.Vertexes.Add(new LwPolylineVertex(5, -5));
            poly2.Vertexes.Add(new LwPolylineVertex(5, 5));
            poly2.Vertexes.Add(new LwPolylineVertex(-5, 5));
            poly2.Vertexes[1].Bulge = -0.25;
            poly2.IsClosed = true;

            LwPolyline poly3 = new LwPolyline();
            poly3.Vertexes.Add(new LwPolylineVertex(-8, -8));
            poly3.Vertexes.Add(new LwPolylineVertex(-6, -8));
            poly3.Vertexes.Add(new LwPolylineVertex(-6, -6));
            poly3.Vertexes.Add(new LwPolylineVertex(-8, -6));
            poly3.IsClosed = true;

            Line line = new Line(new Vector2(-5, -5), new Vector2(5, -5));
            List<HatchBoundaryPath> boundary = new List<HatchBoundaryPath>{
                                                                            new HatchBoundaryPath(new List<EntityObject>{line, poly}),
                                                                            new HatchBoundaryPath(new List<EntityObject>{poly2}),
                                                                            new HatchBoundaryPath(new List<EntityObject>{poly3}),
                                                                          };
            Hatch hatch = new Hatch(HatchPattern.Net, boundary);
            hatch.Layer = new Layer("hatch")
                              {
                                  Color = AciColor.Red,
                                  LineType = LineType.Continuous
                              };
            hatch.Pattern.Angle = 30;
            hatch.Elevation = 52;
            hatch.Normal = new Vector3(1,1,0);
            hatch.Pattern.Scale = 1 / hatch.Pattern.LineDefinitions[0].Delta.Y;
            //dxf.AddEntity(poly);
            //dxf.AddEntity(poly2);
            //dxf.AddEntity(poly3);
            dxf.AddEntity(hatch);
            dxf.AddEntity(hatch.CreateWCSBoundary());

            dxf.Save("hatchTest1.dxf");
            dxf = DxfDocument.Load("hatchTest1.dxf");
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: NTUST-PTL/PTL-Project
        private static void HatchTest2()
        {
            DxfDocument dxf = new DxfDocument();

            LwPolyline poly = new LwPolyline();
            poly.Vertexes.Add(new LwPolylineVertex(-10, -10));
            poly.Vertexes.Add(new LwPolylineVertex(10, -10));
            poly.Vertexes.Add(new LwPolylineVertex(10, 10));
            poly.Vertexes.Add(new LwPolylineVertex(-10, 10));
            poly.Vertexes[2].Bulge = 1;
            poly.IsClosed = true;

            Circle circle = new Circle(Vector3.Zero, 5);

            Ellipse ellipse = new Ellipse(Vector3.Zero,16,10);
            ellipse.Rotation = 30;
            List<HatchBoundaryPath> boundary = new List<HatchBoundaryPath>{
                                                                            new HatchBoundaryPath(new List<EntityObject>{poly}),
                                                                            new HatchBoundaryPath(new List<EntityObject>{circle}),
                                                                            new HatchBoundaryPath(new List<EntityObject>{ellipse})
                                                                          };

            Hatch hatch = new Hatch(HatchPattern.Line, boundary);
            hatch.Pattern.Angle = 150;
            hatch.Pattern.Scale = 5;
            hatch.Normal = new Vector3(1,1,1);
            hatch.Elevation = 23;
            //dxf.AddEntity(poly);
            //dxf.AddEntity(circle);
            //dxf.AddEntity(ellipse);
            dxf.AddEntity(hatch);
            dxf.AddEntity(hatch.CreateWCSBoundary());
            dxf.Save("hatchTest2.dxf");
            dxf = DxfDocument.Load("hatchTest2.dxf");
            dxf.Save("hatchTest2 copy.dxf");
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: NTUST-PTL/PTL-Project
        private static void HatchTestLinesBoundary()
        {
            DxfDocument dxf = new DxfDocument();

            Line line1 = new Line(new Vector3(-10,-10,0),new Vector3(10,-10,0));
            Line line2 = new Line(new Vector3(10, -10, 0), new Vector3(10, 10, 0));
            Line line3 = new Line(new Vector3(10, 10, 0), new Vector3(-10, 10, 0));
            Line line4 = new Line(new Vector3(-10, 10, 0), new Vector3(-10, -10, 0));


            List<HatchBoundaryPath> boundary = new List<HatchBoundaryPath>{
                                                                            new HatchBoundaryPath(new List<EntityObject>{line1, line2, line3, line4})
                                                                          };
            Hatch hatch = new Hatch(HatchPattern.Line, boundary);
            hatch.Layer = new Layer("hatch")
            {
                Color = AciColor.Red,
                LineType = LineType.Dashed
            };
            hatch.Elevation = 52;
            hatch.Pattern.Angle = 45;
            hatch.Pattern.Scale = 10;
            hatch.Normal = new Vector3(1, 1, 1);

            XData xdata = new XData(new ApplicationRegistry("netDxf"));
            xdata.XDataRecord.Add(new XDataRecord(XDataCode.String, "extended data with netDxf"));
            xdata.XDataRecord.Add(XDataRecord.OpenControlString);
            xdata.XDataRecord.Add(new XDataRecord(XDataCode.String, "netDxf hatch"));
            xdata.XDataRecord.Add(new XDataRecord(XDataCode.Distance, hatch.Pattern.Scale));
            xdata.XDataRecord.Add(new XDataRecord(XDataCode.Real, hatch.Pattern.Angle));
            xdata.XDataRecord.Add(XDataRecord.CloseControlString);

            hatch.XData.Add(xdata);

            //dxf.AddEntity(line1);
            //dxf.AddEntity(line2);
            //dxf.AddEntity(line3);
            //dxf.AddEntity(line4);
            dxf.AddEntity(hatch);
            dxf.AddEntity(hatch.CreateWCSBoundary());

            dxf.Save("hatchTest.dxf");
        }