C# 读取DXF文件

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

using System;

using System.Collections.Generic;

using ponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using System.IO;

using System.Collections;

namespace DXF

{

public partial class Form1 : Form

{

精选范本

private FileStream fs;

private StreamReader sr;

private ArrayList LayerList = new ArrayList();

private ArrayList LineList = new ArrayList();

private ArrayList ArcList=new ArrayList();

private ArrayList EllipseList = new ArrayList();

private ArrayList LwopolylineList = new ArrayList();

private ArrayList SplineList=new ArrayList();

private string[] str = new string[2];

private int count;

private double leftx;

private double lefty;

private double rightx;

精选范本

private double righty;

public Form1()

{

InitializeComponent();

}

private string[] ReadPair()

{

string code = sr.ReadLine().Trim();

string codedata = sr.ReadLine().Trim();

count += 2;

string[] result = new string[2] { code, codedata };

return result;

精选范本

}

private void Read()

{

while (sr.Peek() != -1)

{

str = ReadPair();

if (str[1] == "SECTION")

{

str = ReadPair();

switch (str[1])

{

case"HEADER": ReadHeader();

break;

精选范本

case"TABLES": ReadTable();

break;

case"ENTITIES": ReadEntities();

break;

}

}

}

sr.Close();

fs.Close();

btDraw.Enabled = true;

label1.Text = count.ToString();

count = 0;

}

精选范本

private void ReadTable()

{

while (str[1] != "ENDSEC")

{

while (str[0] != "2" || str[1] != "LAYER")

{

str = ReadPair();

}

while (str[0] != "0" || str[1] != "LAYER")

{

str = ReadPair();

}

while (str[0] == "0" && str[1] == "LAYER")

精选范本

{

ReadLAYER();

}

while (str[1] != "ENDSEC")

{

str = ReadPair();

}

}

}

private void ReadLAYER()

{

LAYER newlayer = new LAYER();

while (str[1] != "ENDTAB")

精选范本

{

str = ReadPair();

switch (str[0])

{

case"2": = str[1];

break;

case"62": newlayer.colornum = str[1];

break;

case"6": newlayer.lstyle = str[1];

break;

case"370": newlayer.lwidth = str[1];

break;

}

精选范本

if (str[0] == "0" && str[1] == "LAYER")

{

LayerList.Add(newlayer);

return;

}

}

LayerList.Add(newlayer);

}

private void ReadEntities()

{

while (str[1] != "ENDSEC")

{

switch (str[1])

精选范本

相关文档
最新文档