Ejemplo n.º 1
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(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();
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
        }