C#CAD开发:勘测定界数据成图

public static void AddKCDJPL()
{
    Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
    Editor ed = doc.Editor;
    Database db = doc.Database;
    OpenFileDialog openFileDialog = new OpenFileDialog();
    openFileDialog.Filter = "文本文件|*.txt";
    if (openFileDialog.ShowDialog() == DialogResult.OK)
    {
        string dataPath = openFileDialog.FileName;
        using (Transaction trans = db.TransactionManager.StartTransaction())
        {
            string[] pts = File.ReadAllLines(dataPath, Encoding.UTF8);
            for (int i = 12; i < pts.Length; i++)
            {
                string txtLine = pts[i];
                if (txtLine.Contains("@"))
                {
                    Polyline pl = new Polyline();
                    string[] ss = txtLine.Split(new char[] { ',' });
                    string countStr = ss[0];
                    int jdCount = Convert.ToInt32(countStr);
                    string dkName = ss[3];
                    DBText text = new DBText();
                    text.Height = 50;
                    text.TextString = dkName;
                    int k = 0;
                    for (int j = i + 1; j < i + 1 + jdCount; j++)
                    {
                        string ptLine = pts[j];
                        string[] ptStr = ptLine.Split(new char[] { ',' });
                        string dhStr = ptStr[0];
                        string xStr = ptStr[3];
                        string yStr = ptStr[2];
                        double x = double.Parse(xStr);
                        double y = double.Parse(yStr);
                        text.Position = new Point3d(x, y, 0);
                        pl.AddVertexAt(k, new Point2d(x, y), 0, 0, 0);
                        k++;
                    }
                    pl.Closed = true;
                    pl.ColorIndex = 1;

                    AddEntity.AddEntToModeSpace(db, pl);
                    AddEntity.AddEntToModeSpace(db, text);
                }
                else
                {
                    continue;
                }
            }
            trans.Commit();
        }
    }
}

 

初次使用时,将《勘界测量》文件夹复制到您的"D"盘下,启动CASS, 在命令行(command:)下输入config命令,将《勘界测量》添加到"支持文件搜索路径"中 再在在命令行(command:)下输入menuload命令,将《勘界测量》文件夹中xiaobo.mns文件加载到系统中, 再点击"菜单栏"将"勘界测量"下拉菜单插入到AutoCAD菜单中即可. 《勘界测量》所定义命令说明: tf ;根据界址点生成界址点点之记 ma ;统计地块分类面积(须用"勘界测量"下拉菜单中相关命令将地类分别圈出来) exte ;打散文字 pladp ;多义线孤线段加点 plf ;根据中线生成坐标文件 fcx ;绘房屋分层线(线型为X5,编码:141001) zhxx ;等高线在处理前转换新线形 dg ;等高线连接修改 dht ;绘电话亭符号 fd ;根据点名查询点位并居中显示(CASS6.1版本下) readp ;根据图面点生成数据文件(CASS格式)且将高程小于600米的点的高程改为0 cl ;图形垃圾清理 dgxg ;批量改等高线值 jg ;根据等高线内插高程点 (等高线必须带高,且相邻等高线高差不要>5m) spl2pl ;样条线(SPLINE)转复合线(POLYLINE) jqx ;计曲线注记取位 retm ;根据文件夹里的文件生成索引文件 gtm ;根据索引数据文件批量改文件名(索引文件格式:老文件名,新文件名) plpt ;根据索引数据文件批量插入图块 rp ;根据中线生成横断面数据 jian ;绘简单房屋 gcd ;手工展绘高程点 jg ;根据等高线内插高程点 jgcd ;自动加注高程点 yt ;绘阳台
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

GisSurvey

谢谢您的支持,我将继续努力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值