Example #1
0
        static void Main(string[] args)
        {
            DXFLibrary.Document doc = new DXFLibrary.Document();

            DXFLibrary.Tables tables = new DXFLibrary.Tables();
            doc.SetTables(tables);

            DXFLibrary.Table layers = new DXFLibrary.Table("LAYER");
            tables.addTable(layers);

            DXFLibrary.Layer layerDoors;
            layerDoors = new DXFLibrary.Layer("Doors", 30, "CONTINUOUS");
            layers.AddTableEntry(layerDoors);

            DXFLibrary.Circle cc = new DXFLibrary.Circle(5, 5, 0.1d, "PartialHeightDoors");
            doc.add(cc);

            DXFLibrary.Line line1 = new DXFLibrary.Line("Doors", 0, 0, 0, 10);
            doc.add(line1);
            DXFLibrary.Line line2 = new DXFLibrary.Line("Doors", 0, 0, 10, 0);
            doc.add(line2);
            DXFLibrary.Line line3 = new DXFLibrary.Line("Doors", 10, 10, 0, 10);
            doc.add(line3);
            DXFLibrary.Line line4 = new DXFLibrary.Line("Doors", 10, 10, 10, 0);
            doc.add(line4);

            DXFLibrary.Line3D line5 = new DXFLibrary.Line3D("Doors", 2, 2, 0, 5, 5, 10);
            doc.add(line5);

            FileStream f1 = new FileStream("test2.dxf", System.IO.FileMode.Create);

            DXFLibrary.Writer.Write(doc, f1);
            f1.Close();
        }
        //**CONSTRUCTOR
        internal ExportLinesToDXF(List<PolyCurve[]> polycurves, string filename)
        {
            DXFLibrary.Document dxf = new DXFLibrary.Document();
            DXFLibrary.Tables tables = new DXFLibrary.Tables();
            dxf.SetTables(tables);
            DXFLibrary.Table layers = new DXFLibrary.Table("LAYER");
            tables.addTable(layers);
            DXFLibrary.Layer layer = new DXFLibrary.Layer("PROFILES", 30, "CONTINUOUS");
            layers.AddTableEntry(layer);

            List<Curve> Curves = new List<Curve>();
            for (int i = 0; i < polycurves.Count; i++) for (int j = 0; j < polycurves[i].Length; j++) for (int k = 0; k < polycurves[i][j].Curves().Length; k++)
                Curves.AddRange(polycurves[i][j].Curves()[k].ApproximateWithArcAndLineSegments());
            for (int i = 0; i < Curves.Count; i++)
            {
                DXFLibrary.Line line = new DXFLibrary.Line(
                    "PROFILES",
                    Curves[i].StartPoint.X,
                    Curves[i].StartPoint.Y,
                    Curves[i].StartPoint.Z,
                    Curves[i].EndPoint.X,
                    Curves[i].EndPoint.Y,
                    Curves[i].EndPoint.Z);
                dxf.add(line);
            }
            Curves.ForEach(c => c.Dispose());
            using (FileStream f1 = new FileStream(filename, FileMode.Create))
            {
                DXFLibrary.Writer.Write(dxf, f1);
                f1.Close();
            }
        }
Example #3
0
        /// <summary>
        /// 绘制车站线
        /// </summary>
        /// <param name="doc">DXF文件对象</param>
        /// <param name="layers">图层集合对象</param>
        private void DrawStations(DXFLibrary.Document doc, DXFLibrary.Table layers)
        {
            DXFLibrary.Layer layerStations;
            layerStations = new DXFLibrary.Layer("Stations", 84, "CONTINUOUS");/*创建车站线图层*/
            layers.AddTableEntry(layerStations);

            DXFLibrary.Layer layerBlocks;
            layerBlocks = new DXFLibrary.Layer("Blocks", 84, "CONTINUOUS");/*创建运行图区块边框图层*/
            layers.AddTableEntry(layerBlocks);

            /*绘制各图块的车站线*/
            foreach (DiagramBlock db in BlockSet)
            {
                db.Draw(doc);
            }
        }
Example #4
0
        /// <summary>
        /// 绘制列车
        /// </summary>
        /// <param name="doc">DXF文件对象</param>
        /// <param name="layers">图层集合对象</param>
        private void DrawTrains(DXFLibrary.Document doc, DXFLibrary.Table layers)
        {
            DXFLibrary.Layer layerTrains;
            layerTrains = new DXFLibrary.Layer("Trains", 10, "CONTINUOUS");/*创建列车图层*/
            layers.AddTableEntry(layerTrains);

            DXFLibrary.Layer layerTrainID;
            layerTrainID = new DXFLibrary.Layer("TrainID", 10, "CONTINUOUS");/*创建列车车次标志图层*/
            layers.AddTableEntry(layerTrainID);

            DXFLibrary.Layer layerTrainTime;
            layerTrainTime = new DXFLibrary.Layer("TrainTime", 10, "CONTINUOUS");/*创建列车时刻图层*/
            layers.AddTableEntry(layerTrainTime);

            /*绘制列车运行线*/
            foreach (DTrain tr in TrainSet)
            {
                tr.Draw(doc);
            }
        }
Example #5
0
        /// <summary>
        /// 绘制时间线
        /// </summary>
        /// <param name="doc">DXF文件对象</param>
        /// <param name="layers">图层集合对象</param>
        private void DrawTimeLine(DXFLibrary.Document doc, DXFLibrary.Table layers)
        {
            DXFLibrary.Layer layerTimes;
            layerTimes = new DXFLibrary.Layer("Times", 84, "CONTINUOUS");/*创建一般时间线图层*/
            layers.AddTableEntry(layerTimes);

            DXFLibrary.Layer layerHalfTimes;
            layerHalfTimes = new DXFLibrary.Layer("HalfTimes", 84, "CONTINUOUS");/*创建半小时线图层*/
            layers.AddTableEntry(layerHalfTimes);

            DXFLibrary.Layer layerHourTimes;
            layerHourTimes = new DXFLibrary.Layer("HourTimes", 84, "CONTINUOUS");/*创建小时线图层*/
            layers.AddTableEntry(layerHourTimes);

            /*绘制时间线*/
            foreach (DTime t in TimeSet)
            {
                t.Draw(doc);
            }
        }
 //**CONSTRUCTOR
 internal ExportToDXF()
 {
     // dxflibrary document implementation
     dxf = new DXFLibrary.Document();
     tables = new DXFLibrary.Tables();
     dxf.SetTables(tables);
     layers = new DXFLibrary.Table("LAYER");
     tables.addTable(layers);
     layerNames = new List<string>();
     DXFLibrary.Layer layer = new DXFLibrary.Layer("0", 7, "CONTINUOUS");
     layers.AddTableEntry(layer);
     layerNames.Add("0");
 }
 //**INTERNAL**METHODS
 internal void CheckLayer(string layerName, short ACADcolor)
 {
     if (!layerNames.Contains(layerName))
     {
         DXFLibrary.Layer layer = new DXFLibrary.Layer(layerName, ACADcolor, "CONTINUOUS");
         layers.AddTableEntry(layer);
         layerNames.Add(layerName);
     }
 }