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

 

转载于:https://www.cnblogs.com/luny147258/p/5693528.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值