예제 #1
0
 //--------------------------------------------------------------------------------------------------------------------------------------------------------------
 private void Duplicate_Type(object sender, RoutedEventArgs e)
 {
     try
     {
         category_data item      = (category_data)category.SelectedItem;
         type_data     item_type = (type_data)type.SelectedItem;
         if (new FilteredElementCollector(doc).OfClass(typeof(FamilySymbol)).Where(x => x.Name == item_type.type.Name).ToList().Count() == 0)
         {
             if (double.TryParse(b.Text, out double x) && item.single_value != myAll_Data.list_category_draw[0])
             {
                 Data_For_Extenal_Draw();
                 myExternal_Draw.command = "Duplicate Type";
                 Draw.Raise();
             }
         }
         else
         {
             if (double.TryParse(b.Text, out double x) && double.TryParse(h.Text, out double y))
             {
                 Data_For_Extenal_Draw();
                 myExternal_Draw.command = "Duplicate Type";
                 Draw.Raise();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
예제 #2
0
        //----------------------------------------------------------
        public void Get_Family(Document doc, ComboBox category, ComboBox family, All_Data myAll_Data)
        {
            mySupport_All = new Support_All();
            try
            {
                category_data item = (category_data)category.SelectedItem;

                ElementMulticategoryFilter filter_category = new ElementMulticategoryFilter(new List <BuiltInCategory>()
                {
                    item.builtin
                });
                my_family_data = new ObservableCollection <family_data>(new FilteredElementCollector(doc)
                                                                        .WherePasses(filter_category)
                                                                        .WhereElementIsElementType()
                                                                        .Cast <ElementType>()
                                                                        .GroupBy(x => new
                {
                    x.FamilyName,
                })
                                                                        .ToList().Select(x => new family_data()
                {
                    single_value = x.Key.FamilyName,
                    path_image   = mySupport_All.CreatePreview(x.First(), myAll_Data),
                    types        = x.Select(y => y).ToList()
                }).OrderBy(x => x.single_value));

                family.ItemsSource   = my_family_data;
                family.SelectedIndex = 0;

                CollectionView view_family = (CollectionView)CollectionViewSource.GetDefaultView(family.ItemsSource);
                view_family.SortDescriptions.Add(new SortDescription("single_value", ListSortDirection.Ascending));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #3
0
        //----------------------------------------------------------
        public void Get_Parameter(Element element_update, Document doc,
                                  ComboBox category, ComboBox family, ComboBox type, ListView thong_tin_parameter,
                                  All_Data myAll_Data)
        {
            mySupport_All = new Support_All();
            try
            {
                category_data item_cate = (category_data)category.SelectedItem;
                family_data   item      = (family_data)family.SelectedItem;
                type_data     item_type = (type_data)type.SelectedItem;

                ElementMulticategoryFilter filter_category = new ElementMulticategoryFilter(new List <BuiltInCategory>()
                {
                    item_cate.builtin
                });
                if (item != null && item.single_value != "" && new FilteredElementCollector(doc).OfClass(typeof(FamilySymbol)).Where(x => x.Name == item_type.type.Name).ToList().Count() > 0)
                {
                    var list_element = new FilteredElementCollector(doc)
                                       .WherePasses(filter_category)
                                       .WhereElementIsNotElementType()
                                       .Where(x => (x as FamilyInstance).Symbol.FamilyName == item.single_value)
                                       .Where(x => x.Name == item_type.single_value)
                                       .ToList();

                    if (element_update != null)
                    {
                        my_parameter_data = new ObservableCollection <parameter_data>(mySupport_All.View_Dimensions_FamilySymbol(doc, element_update, myAll_Data));
                    }
                    else if (list_element.Count() > 0)
                    {
                        my_parameter_data = new ObservableCollection <parameter_data>(mySupport_All.View_Dimensions_FamilySymbol(doc, list_element[0], myAll_Data));
                    }
                    else
                    {
                        Family fa = new FilteredElementCollector(doc).OfClass(typeof(Family)).Cast <Family>().Where(x => x.Name == item.single_value).First();
                        my_parameter_data = new ObservableCollection <parameter_data>();
                        if (fa.IsEditable)
                        {
                            Document      familyDoc = doc.EditFamily(fa);
                            FamilyManager manager   = familyDoc.FamilyManager;

                            foreach (FamilyParameter para in manager.Parameters)
                            {
                                try
                                {
                                    if (para.IsInstance && para.Definition.ParameterGroup == BuiltInParameterGroup.PG_GEOMETRY && mySource.para_name_not_use.Contains(para.Definition.Name) == false && para.IsReadOnly == false)
                                    {
                                        my_parameter_data.Add(new parameter_data()
                                        {
                                            parameter_name  = para.Definition.Name,
                                            parameter_value = mySupport_All.Get_Parameter_Information_Family(para, familyDoc, manager, myAll_Data),
                                            parameter       = null
                                        });
                                    }
                                }
                                catch (Exception)
                                {
                                }
                            }
                            familyDoc.Close(false);
                        }
                    }

                    thong_tin_parameter.ItemsSource = my_parameter_data;
                }
                else
                {
                    thong_tin_parameter.ItemsSource = new ObservableCollection <parameter_data>();
                }

                CollectionView view_para = (CollectionView)CollectionViewSource.GetDefaultView(thong_tin_parameter.ItemsSource);
                view_para.SortDescriptions.Add(new SortDescription("parameter_name", ListSortDirection.Ascending));
            }
            catch (Exception ex)
            {
                ////MessageBox.Show(ex.Message);
            }
        }