Esempio n. 1
0
        public static void DetectSelfIntersection() // mod 20130202
        {
            ObjectId[]    ids   = QuickSelection.SelectAll("LWPOLYLINE").ToArray();
            ProgressMeter meter = new ProgressMeter();

            meter.Start("Detecting...");
            meter.SetLimit(ids.Length);
            var results = ids.QWhere(x =>
            {
                bool result = (x 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.");
            }
        }
Esempio n. 2
0
 public void TestQOpen()
 {
     ObjectId[] ids = QuickSelection.SelectAll("LWPOLYLINE").QWhere(x => x.GetCode() == "parcel").ToArray();
     ids.QForEach <Polyline>(x =>
     {
         x.ConstantWidth = 2;
         x.ColorIndex    = 0;
     });
 }
Esempio n. 3
0
        public static void SelectByLayer()
        {
            string[] options = DbHelper.GetAllLayerNames();
            string[] 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);
        }
Esempio n. 4
0
        public static void GetLinesOfPoint()
        {
            var p = Interaction.GetPoint("GetLineOfPoint");

            //Interaction.GetEntity()
            //Interaction.
            Interaction.GetEntitysByLayers();
            var ids = QuickSelection.SelectAll();

            foreach (ObjectId id in ids)
            {
            }
        }
Esempio n. 5
0
        public static void ShowObject()
        {
            ObjectId[] 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);
        }
Esempio n. 6
0
        public static void PolyLanding()
        {
            ObjectId[]      ids            = QuickSelection.SelectAll("*LINE,ARC").ToArray();
            List <ObjectId> landingLineIds = new List <ObjectId>();

            while (true)
            {
                Point3d p = Interaction.GetPoint("\nSpecify a point");
                if (p.IsNull())
                {
                    break;
                }
                Point3d[] landings = ids.QSelect(x => (x as Curve).GetClosestPointTo(p, false)).ToArray();
                double    minDist  = landings.Min(x => x.DistanceTo(p));
                Point3d   landing  = landings.First(x => x.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);
                ObjectId landingLineId = Draw.Line(p, landing);
                landingLineIds.Add(landingLineId);
            }
            landingLineIds.QForEach(x => x.Erase());
        }
Esempio n. 7
0
        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(x => !x.Layer.Contains("_Label")).QSelect(x => x.Layer).Distinct().Select(x => string.Format("{0}_Label", x)).ToList().ForEach(x => DbHelper.GetLayerId(x));
            }
            else
            {
                var    layers = DbHelper.GetAllLayerNames().Where(x => !x.Contains("_Label")).ToArray();
                string layer  = Gui.GetChoice("Select a layer", layers);
                ids = QuickSelection.SelectAll().QWhere(x => x.Layer == layer).ToArray();
                DbHelper.GetLayerId(string.Format("{0}_Label", layer));
            }
            var texts = new List <MText>();

            ids.QForEach <Entity>(ent =>
            {
                string layerName = ent.Layer;
                if (!layerName.Contains("_Label"))
                {
                    Point3d center = ent.GetCenter();
                    MText text     = NoDraw.MText(layerName, height, center, 0, true);
                    text.Layer     = string.Format("{0}_Label", layerName);
                    texts.Add(text);
                }
            });
            texts.ToArray().AddToCurrentSpace();
        }
Esempio n. 8
0
 public void TestBlock()
 {
     var bId = Draw.Block(QuickSelection.SelectAll(), "test");
 }