text转表格

  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;
        }

 

posted @ 2016-07-21 23:13  BurdeNing  阅读(223)  评论(0编辑  收藏  举报