Пример #1
0
        public static void SaveSelection()
        {
            var ids = Interaction.GetPickSet();

            if (ids.Length == 0)
            {
                Interaction.WriteLine("No entity selected.");
                return;
            }
            string name = Interaction.GetString("\nSelection name");

            if (name == null)
            {
                return;
            }
            if (CustomDictionary.GetValue("Selections", name) != string.Empty)
            {
                Interaction.WriteLine("Selection with the same name already exists.");
                return;
            }
            var    handles   = ids.QSelect(x => x.Handle.Value.ToString()).ToArray();
            string dictValue = string.Join("|", handles);

            CustomDictionary.SetValue("Selections", name, dictValue);
        }
Пример #2
0
 public void TestCustomDictionary()
 {
     CustomDictionary.SetValue("dict1", "A", "apple");
     CustomDictionary.SetValue("dict1", "B", "orange");
     CustomDictionary.SetValue("dict1", "A", "banana");
     CustomDictionary.SetValue("dict2", "A", "peach");
     foreach (var dict in CustomDictionary.GetDictionaryNames())
     {
         Interaction.WriteLine(dict);
     }
     Interaction.WriteLine(CustomDictionary.GetValue("dict1", "A"));
 }
Пример #3
0
        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());
        }