コード例 #1
0
        public static void DetectSelfIntersection() // mod 20130202
        {
            var ids   = QuickSelection.SelectAll("LWPOLYLINE").ToArray();
            var meter = new ProgressMeter();

            meter.Start("Detecting...");
            meter.SetLimit(ids.Length);
            var results = ids.QWhere(pline =>
            {
                bool result = (pline as Polyline).IsSelfIntersecting();
                meter.MeterProgress();
                System.Windows.Forms.Application.DoEvents();
                return(result);
            }).ToList();

            meter.Stop();
            if (results.Count() > 0)
            {
                Interaction.WriteLine("{0} detected.", results.Count());
                Interaction.ZoomHighlightView(results);
            }
            else
            {
                Interaction.WriteLine("0 detected.");
            }
        }
コード例 #2
0
        //public static ObjectId[] GetEntitysByLayer(string layer)
        //{
        //    var ids = QuickSelection
        //       .SelectAll(FilterList.Create().Layer(layer))
        //       .ToArray();
        //    return ids;
        //}

        public static ObjectId[] GetEntitysByLayers(params string[] layers)
        {
            var ids = QuickSelection
                      .SelectAll(FilterList.Create().Layer(layers))
                      .ToArray();

            return(ids);
        }
コード例 #3
0
        public void TestQOpen()
        {
            var ids = QuickSelection.SelectAll("LWPOLYLINE").QWhere(pline => pline.GetCode() == "parcel").ToArray();

            ids.QForEach <Polyline>(poly =>
            {
                poly.ConstantWidth = 2;
                poly.ColorIndex    = 0;
            });
        }
コード例 #4
0
ファイル: Test.cs プロジェクト: xibeilang524/LocationSystem
        public static void ShowLayerName()
        {
            double height = 10;

            string[] range  = { "By entities", "By layers" };
            int      result = Gui.GetOption("Choose one way", range);

            if (result == -1)
            {
                return;
            }
            ObjectId[] ids;
            if (result == 0)
            {
                ids = Interaction.GetSelection("\nSelect entities");
                ids
                .QWhere(entity => !entity.Layer.Contains("_Label"))
                .QSelect(entity => entity.Layer)
                .Distinct()
                .Select(layer => $"{layer}_Label")
                .ForEach(labelLayer => DbHelper.GetLayerId(labelLayer));
            }
            else
            {
                var    layers    = DbHelper.GetAllLayerNames().Where(layer => !layer.Contains("_Label")).ToArray();
                string layerName = Gui.GetChoice("Select a layer", layers);
                ids = QuickSelection
                      .SelectAll(FilterList.Create().Layer(layerName))
                      .ToArray();

                DbHelper.GetLayerId($"{layerName}_Label");
            }

            List <string> layerNames = new List <string>();

            var texts = new List <MText>();

            ids.QForEach <Entity>(entity =>
            {
                string layerName = entity.Layer;
                layerNames.Add(layerName);
                if (!layerName.Contains("_Label"))
                {
                    var center = entity.GetCenter();
                    var text   = NoDraw.MText(layerName, height, center, 0, true);
                    text.Layer = $"{layerName}_Label";
                    texts.Add(text);
                }
            });
            //int result2 = Gui.GetOption("Layernames", layerNames.ToArray());
            texts.ToArray().AddToCurrentSpace();
        }
コード例 #5
0
        public static void SelectByLayer()
        {
            var options = DbHelper.GetAllLayerNames();
            var opt     = Gui.GetChoices("Specify layers", options);

            if (opt.Length < 1)
            {
                return;
            }
            var ids = QuickSelection.SelectAll().QWhere(x => opt.Contains(x.Layer)).ToArray();

            Interaction.SetPickSet(ids);
        }
コード例 #6
0
        public static void SelectByLayer()
        {
            var availableLayerNames = DbHelper.GetAllLayerNames();
            var selectedLayerNames  = Gui.GetChoices("Specify layers", availableLayerNames);

            if (selectedLayerNames.Length < 1)
            {
                return;
            }

            var ids = QuickSelection
                      .SelectAll(FilterList.Create().Layer(selectedLayerNames))
                      .ToArray();

            Interaction.SetPickSet(ids);
        }
コード例 #7
0
        public static void ShowObject()
        {
            var    ids     = QuickSelection.SelectAll().ToArray();
            double handle1 = Interaction.GetValue("Handle of entity");

            if (double.IsNaN(handle1))
            {
                return;
            }
            long handle2 = Convert.ToInt64(handle1);
            var  id      = HostApplicationServices.WorkingDatabase.GetObjectId(false, new Handle(handle2), 0);
            var  col     = new ObjectId[] { id };

            Interaction.HighlightObjects(col);
            Interaction.ZoomObjects(col);
        }
コード例 #8
0
        public static void PolyLanding()
        {
            var ids            = QuickSelection.SelectAll("*LINE,ARC").ToArray();
            var landingLineIds = new List <ObjectId>();

            while (true)
            {
                var p = Interaction.GetPoint("\nSpecify a point");
                if (p.IsNull())
                {
                    break;
                }
                var    landings = ids.QSelect(entity => (entity as Curve).GetClosestPointTo(p, false)).ToArray();
                double minDist  = landings.Min(point => point.DistanceTo(p));
                var    landing  = landings.First(point => point.DistanceTo(p) == minDist);
                Interaction.WriteLine("Shortest landing distance of point ({0:0.00},{1:0.00}) is {2:0.00}.", p.X, p.Y, minDist);
                landingLineIds.Add(Draw.Line(p, landing));
            }
            landingLineIds.QForEach(entity => entity.Erase());
        }
コード例 #9
0
ファイル: QuickSelection.cs プロジェクト: presscad/CAM
 /// <summary>
 /// Selects all entities with specified filters in current editor.
 /// </summary>
 /// <param name="filterList">The filter list.</param>
 /// <returns>The object IDs.</returns>
 public static ObjectId[] SelectAll(FilterList filterList)
 {
     return(QuickSelection.SelectAll(filterList.ToArray()));
 }
コード例 #10
0
ファイル: QuickSelection.cs プロジェクト: presscad/CAM
 /// <summary>
 /// Selects all entities with specified DXF type in current editor.
 /// </summary>
 /// <param name="dxfType">The DXF type.</param>
 /// <returns>The object IDs.</returns>
 public static ObjectId[] SelectAll(string dxfType)
 {
     return(QuickSelection.SelectAll(new TypedValue((int)DxfCode.Start, dxfType)));
 }
コード例 #11
0
 public void TestBlock()
 {
     var bId = Draw.Block(QuickSelection.SelectAll(), "test");
     // TODO: complete this test.
 }