码迷,mamicode.com
首页 > 其他好文 > 详细

text转表格

时间:2016-07-22 01:11:43      阅读:175      评论:0      收藏:0      [点我收藏+]

标签:

  public static Point3dCollection IntersectAny(DBObjectCollection dbs)
        {
            Point3dCollection pts = new Point3dCollection();
            Database db = dbs[0].Database;
            using (Transaction trans = db.TransactionManager.StartTransaction())
            {
                List<Entity> ents = new List<Entity>();
                Point3dCollection ptcol = new Point3dCollection();
                foreach (DBObject dbn in dbs)
                {
                    try
                    {
                        Entity ent = (Entity)trans.GetObject(dbn.ObjectId, OpenMode.ForRead);
                        ents.Add(ent);
                    }
                    catch
                    {
                        continue;
                    }
                }
                while (ents.Count != 0)
                {
                    Entity crv = ents[0];
                    ents.Remove(crv);
                    ptcol.Clear();
                    foreach (Entity entn in ents)
                    {
                        entn.IntersectWith(crv, Intersect.OnBothOperands, new Plane(), ptcol, (int)0, (int)0);
                    }
                    if (ptcol.Count != 0)
                    {
                        foreach (Point3d pt in ptcol)
                        {
                            if (!pts.Contains(pt))
                            {
                                pts.Add(pt);
                            }
                        }
                    }
                }
            }
            return pts;
        }

        public static List<List<Point3d>> pointSort(Point3dCollection pts)
        {
            List<List<Point3d>> resultList = new List<List<Point3d>>();
             List<double> xlist =new List<double>();
            for (int n = 0; n < pts.Count; n++)
            {
                double y = pts[n].Y;
                if (xlist.Contains(y))
                {
                    resultList[xlist.IndexOf(y)].Add(pts[n]);
                }
                else 
                {
                    resultList.Add(new List<Point3d>{pts[n]});
                    xlist.Add(y);
                }
            }
            foreach (List<Point3d> ptsList in resultList)
            {
                ptsList.OrderBy(p => p.Y);
            }
            resultList.OrderBy(p => p[0].Y);
            return resultList;
        }

 

text转表格

标签:

原文地址:http://www.cnblogs.com/luny147258/p/5693528.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!