Exemplo n.º 1
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);
        }
Exemplo n.º 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");
            }
            var texts = new List <MText>();

            ids.QForEach <Entity>(entity =>
            {
                string layerName = entity.Layer;
                if (!layerName.Contains("_Label"))
                {
                    var center = entity.GetCenter();
                    var text   = NoDraw.MText(layerName, height, center, 0, true);
                    text.Layer = $"{layerName}_Label";
                    texts.Add(text);
                }
            });
            texts.ToArray().AddToCurrentSpace();
        }
Exemplo n.º 3
0
 /// <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()));
 }
Exemplo n.º 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()));
 }