Exemplo n.º 1
0
        //刷新对象
        private void RefreshObjects()
        {
            if (Sel_Category.SelectedItem != null && Sel_ParameterType != null)
            {
                viewObjects.Clear();

                FilteredElementCollector elements = new FilteredElementCollector(_document);
                Category selCategory = Sel_Category.SelectedItem as Category;
                elements.OfCategory((BuiltInCategory)selCategory.Id.IntegerValue);
                if (Sel_ParameterType.SelectedIndex == 0)
                {
                    foreach (ElementType elementType in elements.WhereElementIsElementType())
                    {
                        ViewObject viewObject = new ViewObject(elementType);
                        viewObjects.Add(viewObject);
                    }
                }
                if (Sel_ParameterType.SelectedIndex == 1)
                {
                    foreach (Element element in elements.WhereElementIsNotElementType())
                    {
                        ViewObject viewObject = new ViewObject(element);
                        viewObjects.Add(viewObject);
                    }
                }
            }
        }
Exemplo n.º 2
0
 //刷新参数选项
 private void RefreshParameter()
 {
     if (Sel_ParameterType.SelectedItem != null)
     {
         parameters.Clear();
         //如果选择了某个对象,使用此对象的参数,否则使用所有对象的共有参数
         if (View_Objects.SelectedItem != null)
         {
             ViewObject viewObject = View_Objects.SelectedItem as ViewObject;
             foreach (Parameter parameter in viewObject.Element.Parameters)
             {
                 if (!parameter.IsReadOnly)
                 {
                     if (parameter.StorageType == StorageType.String)
                     {
                         parameters.Add(parameter);
                     }
                 }
             }
         }
         else
         {
             List <int> set1 = new List <int>();
             foreach (ViewObject viewObject in View_Objects.Items)
             {
                 List <int> set2 = new List <int>();
                 foreach (Parameter parameter in viewObject.Element.Parameters)
                 {
                     if (!parameter.IsReadOnly)
                     {
                         if (parameter.StorageType == StorageType.String)
                         {
                             set2.Add(parameter.Id.IntegerValue);
                         }
                     }
                 }
                 if (set1.Count == 0)
                 {
                     set1 = set2.ToList();
                 }
                 else
                 {
                     set1 = set1.Intersect(set2).ToList();
                 }
             }
             foreach (int i in set1)
             {
                 foreach (ViewObject viewObject in View_Objects.Items)
                 {
                     foreach (Parameter parameter in viewObject.Element.Parameters)
                     {
                         if (!parameter.IsReadOnly && parameter.StorageType == StorageType.String && parameter.Id.IntegerValue == i)
                         {
                             parameters.Add(parameter);
                             break;
                         }
                     }
                     break;
                 }
             }
         }
     }
 }