예제 #1
0
        public void SelectPointAtPolygon()
        {
            Polyline pline;

            if (!ObjectCollector.TrySelectAllowedClassObject(out pline))
            {
                return;
            }

            Vector3d vector = pline.Bounds.Value.MaxPoint - pline.Bounds.Value.MinPoint;

            Point3d centralPoint = pline.Bounds.Value.MinPoint.Add(vector.DivideBy(2d));
            var     randomPoints = centralPoint.CreateRandomCirclePoints(10000, vector.Length);

            List <ObjectId> pointIds = new List <ObjectId>();

            Tools.StartTransaction(() =>
            {
                pointIds = Tools.AppendEntity(
                    randomPoints.Select(x =>
                {
                    return(new DBPoint(x));
                }));
            });

            Tools.StartTransaction(() =>
            {
                foreach (var id in pointIds)
                {
                    DBPoint p = id.GetObjectForRead <DBPoint>();
                    if (pline.IsInsidePolygon(p.Position))
                    {
                        p.UpgradeOpen();
                        p.Highlight();
                    }
                }
            });
        }