首页 > 其他 > 详细

text转表格

时间:2016-07-22 01:09:30      阅读:237      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!