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(); }
public static void LoadSelection() { string name = Gui.GetChoice("Which selection to load?", CustomDictionary.GetEntryNames("Selections").ToArray()); if (name == string.Empty) { return; } string dictValue = CustomDictionary.GetValue("Selections", name); var handles = dictValue.Split('|').Select(x => new Handle(Convert.ToInt64(x))).ToList(); List <ObjectId> ids = new List <ObjectId>(); handles.ForEach(x => { ObjectId id = ObjectId.Null; if (HostApplicationServices.WorkingDatabase.TryGetObjectId(x, out id)) { ids.Add(id); } }); Interaction.SetPickSet(ids.ToArray()); }