Example #1
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);
        }
Example #2
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();
        }
Example #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);
        }
Example #4
0
 /// <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()));
 }
 /// <summary>
 /// Gets multiple entities.
 /// </summary>
 /// <param name="message">The message.</param>
 /// <param name="filterList">The filter list.</param>
 /// <returns>The entity IDs.</returns>
 public static ObjectId[] GetSelection(string message, FilterList filterList)
 {
     return(Interaction.GetSelection(message, filterList.ToArray()));
 }