muli 发表于 2006-10-17 14:33:00

.net开发的从text读取特定格式数据并生成图形

我是一个初学者,不懂编程,也不懂arx,最近才开始学C#.net + ARX开发CAD,刚作出一个小程序,与初学的交流一下,也请高手帮我完善一下,因我我没有加异常处理^_^,加了老是“并非所有代码路径都返回值”的错误,所以删了~~~希望谁能帮我改写一下,程序如下:
using System ;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
using System.Collections.Specialized;
using Autodesk..Runtime ;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.ApplicationServices;
//using Autodesk.AutoCAD.Colors;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.EditorInput;

namespace ClassLibrary
{
///
/// Summary description for MyClass.
///
public class MyClass
{
public MyClass()
{
   //
   // TODO: Add constructor logic here
   //
}
static public ObjectId CreateLayer()
{
   ObjectId layerId; //它返回函数的值
   Database db = HostApplicationServices.WorkingDatabase;
   Transaction trans = db.TransactionManager.StartTransaction();
   //首先取得层表……
   LayerTable lt = (LayerTable)trans.GetObject(db.LayerTableId, OpenMode.ForWrite);
   //检查EmployeeLayer层是否存在……
   if (lt.Has("LAJ"))
   {
    layerId = lt["LAJ"];
   }
   else
   {
    //如果EmployeeLayer层不存在,就创建它
    LayerTableRecord ltr = new LayerTableRecord();
    ltr.Name = "LAJ"; //设置层的名字
    ltr.Color = Autodesk.AutoCAD.Colors.Color.FromColorIndex(Autodesk.AutoCAD.Colors.ColorMethod.ByAci, 1);
    layerId = lt.Add(ltr);
    trans.AddNewlyCreatedDBObject(ltr, true);
   }

   trans.Commit();
   trans.Dispose();
   return layerId;
}
static public Point3dCollection InputCoo()
{
   
   &nbspoint3dCollection point3dCollection = new Point3dCollection();
    System.Windows.Forms.OpenFileDialog openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
    OpenFileDialog openFileDialog = new OpenFileDialog();
    openFileDialog1.InitialDirectory =@"D:\Documents and Settings\muli\My Documents\";
    openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
    openFileDialog1.FilterIndex = 1;
    openFileDialog1.RestoreDirectory = true ;
    if (openFileDialog1.ShowDialog() == DialogResult.OK)
    {
      StreamReader sr = new StreamReader(openFileDialog1.FileName,System.Text.Encoding.Default);
      string [] sLine = null;
         ArrayList arrText = new ArrayList();
      //    string delimStr = ",,,";
      //    char [] delimiter = delimStr.ToCharArray();
      while (sr.Peek() != -1)
      {
       string aa = sr.ReadLine();
       string delimStr = " ,";
       char [] delimiter = delimStr.ToCharArray();
       sLine = aa.Split(delimiter);
   
       for (int i = 0; i
}
另,坐标文件的格式如下:
1,X,Y
2,X,Y
3,x,Y
......
其中,分隔符可以是“,”,或者空格。

muli 发表于 2006-10-25 09:45:00

为什么没有高手帮我看一下呢?才哥呢?

cooolseee 发表于 2013-11-18 23:20:00

我也想学I学习
页: [1]
查看完整版本: .net开发的从text读取特定格式数据并生成图形