乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 48|回复: 2

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

[复制链接]

3

主题

8

帖子

3

银币

初来乍到

Rank: 1

铜币
20
发表于 2006-10-17 14:33:00 | 显示全部楼层 |阅读模式
我是一个初学者,不懂编程,也不懂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;
[assembly: CommandClass(typeof(ClassLibrary.MyClass))]
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
......
其中,分隔符可以是“,”,或者空格。
回复

使用道具 举报

3

主题

8

帖子

3

银币

初来乍到

Rank: 1

铜币
20
发表于 2006-10-25 09:45:00 | 显示全部楼层
为什么没有高手帮我看一下呢?才哥呢?
回复

使用道具 举报

14

主题

64

帖子

4

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
120
发表于 2013-11-18 23:20:00 | 显示全部楼层
我也想学I学习
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-14 13:14 , Processed in 0.360396 second(s), 58 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表