Esempio n. 1
0
        public static Line GetUnionLine([NotNull] this List <Line> lines)
        {
            using var wasteLines = new DisposableSet <Line>();
            Line prew      = null !;
            Line?unionLine = null;

            foreach (var l in lines)
            {
                if (prew == null)
                {
                    prew = l;
                    continue;
                }

                var line = prew.GetUnionLine(l);
                wasteLines.Add(line);
                unionLine = prew;
                prew      = line;
            }

            if (unionLine == null)
            {
                return((Line)prew.Clone());
            }

            wasteLines.Remove(prew);
            return(prew);
        }
Esempio n. 2
0
 private static Region GetRegion([NotNull] IEnumerable <Curve> pls)
 {
     using (var regions = new DisposableSet <Region>(pls.CreateRegion()))
     {
         var reg = regions.Skip(1).Any() ? regions.ToList().UnionRegions() : regions.First();
         regions.Remove(reg);
         return(reg);
     }
 }
Esempio n. 3
0
        public static Hatch?CreateHatch(this Region region, bool createOut, out DisposableSet <Polyline>?externalLoops)
        {
            externalLoops = createOut ? new DisposableSet <Polyline>() : null;
            var plsByLoop = region.GetPoints2dByLoopType();
            var extLoops  = plsByLoop.Where(p => p.Value != BrepLoopType.LoopInterior).ToList();
            var intLoops  = plsByLoop.Where(p => p.Value == BrepLoopType.LoopInterior).ToList();

            if (!extLoops.Any())
            {
                return(null);
            }

            var h = new Hatch();

            h.SetHatchPattern(HatchPatternType.PreDefined, "SOLID");

            foreach (var item in extLoops)
            {
                var pts2dCol = item.Key;
                pts2dCol.Add(item.Key[0]);
                h.AppendLoop(HatchLoopTypes.External, pts2dCol, new DoubleCollection(new double[extLoops.Count + 1]));
                if (createOut)
                {
                    externalLoops !.Add(pts2dCol.Cast <Point2d>().ToList().CreatePolyline());
                }
            }

            if (intLoops.Any())
            {
                foreach (var item in intLoops)
                {
                    var pts2dCol = item.Key;
                    pts2dCol.Add(item.Key[0]);
                    h.AppendLoop(HatchLoopTypes.SelfIntersecting, pts2dCol, new DoubleCollection(new double[intLoops.Count + 1]));
                }
            }

            h.EvaluateHatch(true);
            return(h);
        }
Esempio n. 4
0
        public static void FlickObjectHighlight(
            [CanBeNull] this List <ObjectId> ids,
            int num    = 2,
            int delay1 = 50,
            int delay2 = 50)
        {
            if (ids?.Any() != true)
            {
                return;
            }
            var doc = Application.DocumentManager.MdiActiveDocument;

            using (var ents = new DisposableSet <Entity>(ids.Select(s => (Entity)s.Open(OpenMode.ForRead))))
            {
                for (var i = 0; i < num; i++)
                {
                    // Highlight entity
                    foreach (var entity in ents)
                    {
                        entity.Highlight();
                    }

                    doc.Editor.UpdateScreen();

                    // Wait for delay1 msecs
                    Thread.Sleep(delay1);

                    // Unhighlight entity
                    foreach (var entity in ents)
                    {
                        entity.Unhighlight();
                    }

                    doc.Editor.UpdateScreen();

                    // Wait for delay2 msecs
                    Thread.Sleep(delay2);
                }
            }
        }