注册 登录
编程论坛 C# 论坛

以下程序只能读取dxf文件中多段线(二维)的一个点的坐标(左端点),但多段线有三个点,哪位大神能帮忙改改。

余华为 发布于 2014-03-02 13:15, 644 次点击
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            string fn = @"1.dxf";
            ReadDxf rd = new ReadDxf(fn);
            ArrayList abc = new ArrayList();
            abc=rd.ReadPolyline(@"0");

            double[,] ps=new double[abc.Count,2];
            for (int i = 0; i < abc.Count; i++)
            {
                double[] ds = new double[2];
                ds = (double[])abc[i];
                ps[i, 0] = ds[0]; ps[i, 1] = ds[1];


                WriteToFile wtf = new WriteToFile(@"1.txt");
                string[] str = new string[2];
                str[0] = ps[0, 0].ToString("F3");
                str[1] = ps[0, 1].ToString("F3");
                wtf.WriteStringByLine(str);
                wtf.Close();
            }

            

                     
        }
    }
}
(ReadDxf为引用的类)
3 回复
#2
wp2319572014-03-02 13:17
不懂啊
#3
wangnannan2014-03-03 08:38
程序代码:
     WriteToFile wtf = new WriteToFile(@"1.txt");
                string[] str = new string[2];
                str[0] = ps[0, 0].ToString("F3");
                str[1] = ps[0, 1].ToString("F3");
                wtf.WriteStringByLine(str);
                wtf.Close();
这段代码不要放进for循环内部 当然只能存一个了
放到循环外部 等都读取完放到数组里 你在遍历数组 ps 内容在存到文件
#4
余华为2014-03-03 09:46
好的,我试一下
1