public void Function_TXT() { try { myAll_Data = mySupport_All.Get_Data_All(path); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
//---------------------------------------------------------- public void Default_Image(All_Data myAll_Data, List <Image> list_control_image) { try { for (int i = 0; i < list_control_image.Count; i++) { list_control_image[i].Source = new BitmapImage(new Uri(myAll_Data.list_path_image_data.First(x => x.image_name == list_control_image[i].Name).image_path)); } } catch (Exception) { } }
//---------------------------------------------------------- public void Search(Document doc, TextBox search, TextBox elevation_bottom, ComboBox category, ComboBox family, ComboBox type, ListView thong_tin_parameter, All_Data myAll_Data) { try { if (search.Text != "search") { CollectionViewSource.GetDefaultView(type.ItemsSource).Refresh(); type.SelectedItem = my_type_data.First(x => x.single_value.Contains(search.Text)); //Get_Element(); Get_Parameter(null, doc, category, family, type, thong_tin_parameter, myAll_Data); Update_UK_MA(type, myAll_Data, elevation_bottom, thong_tin_parameter); } } catch (Exception ex) { //MessageBox.Show(ex.Message); } }
//---------------------------------------------------------- public void Add_Category(Document doc, ComboBox category, All_Data myAll_Data) { try { my_category_data = new ObservableCollection <category_data>(); var builtin_category = Enum.GetValues(typeof(BuiltInCategory)).Cast <BuiltInCategory>().ToList(); var categories = doc.Settings.Categories; foreach (string name in myAll_Data.list_category_draw) { BuiltInCategory builtInCategory = BuiltInCategory.INVALID; foreach (BuiltInCategory buildCategory in builtin_category) { try { if (categories.get_Item(buildCategory) != null && categories.get_Item(buildCategory).Name == name) { builtInCategory = buildCategory; break; } } catch (Exception) { } } my_category_data.Add(new category_data() { single_value = name, builtin = builtInCategory }); } category.ItemsSource = my_category_data; category.SelectedIndex = 0; CollectionView view_category = (CollectionView)CollectionViewSource.GetDefaultView(category.ItemsSource); view_category.SortDescriptions.Add(new SortDescription("single_value", ListSortDirection.Ascending)); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
//---------------------------------------------------------- public void Update_UK_MA(ComboBox type, All_Data myAll_Data, TextBox elevation_bottom, ListView thong_tin_parameter) { try { type_data item_type = (type_data)type.SelectedItem; double offset = 0; if (item_type.type.get_Parameter(BuiltInParameter.FAMILY_HEIGHT_PARAM) != null) { offset = item_type.type.get_Parameter(BuiltInParameter.FAMILY_HEIGHT_PARAM).AsDouble() * myAll_Data.list_unit_value_data[2]; } my_parameter_data.Where(x => myAll_Data.list_parameter_tag.Contains(x.parameter_name)) .ToList().ForEach(x => x.parameter_value = (Convert.ToDouble(elevation_bottom.Text) + offset).ToString()); thong_tin_parameter.Items.Refresh(); } catch (Exception ex) { } }
//---------------------------------------------------------- public string CreatePreview(ElementType type, All_Data myAll_Data) { string path = ""; try { mySource = new ListSource(); if (Directory.Exists(mySource.user + myAll_Data.list_path_foder_data[1]) == false) { Directory.CreateDirectory(mySource.user + myAll_Data.list_path_foder_data[1]); } Size imgSize = new Size(200, 200); Bitmap image = type.GetPreviewImage(imgSize); // encode image to jpeg for test display purposes: JpegBitmapEncoder encoder = new JpegBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create( ConvertBitmapToBitmapSource(image))); encoder.QualityLevel = 25; path = mySource.user + myAll_Data.list_path_foder_data[1] + "\\" + type.FamilyName + ".jpg"; FileStream file = new FileStream(path, FileMode.Create, FileAccess.Write); encoder.Save(file); file.Close(); } catch (Exception ex) { } return(path); }
//---------------------------------------------------------- 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); } }
//---------------------------------------------------------- public ObservableCollection <parameter_data> View_Dimensions_FamilySymbol(Document doc, Element element, All_Data myAll_Data) { mySource = new ListSource(); ObservableCollection <parameter_data> my_parameter_data = new ObservableCollection <parameter_data>(); try { try { foreach (Parameter para in element.Parameters) { try { if (para.Definition.ParameterGroup == BuiltInParameterGroup.PG_GEOMETRY && mySource.para_name_not_use.Contains(para.Definition.Name) == false && para.IsReadOnly == false) { string value = Get_Parameter_Information(para, doc, myAll_Data); my_parameter_data.Add(new parameter_data() { parameter_name = para.Definition.Name, parameter_value = value, parameter = para }); } } catch (Exception) { } } } catch (Exception) { MessageBox.Show("Bạn cần có ít nhất 1 đối tượng đã được vẽ để lấy thông tin!", "ERROR", MessageBoxButton.OK, MessageBoxImage.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message); } return(my_parameter_data); }
//---------------------------------------------------------- public string Get_Parameter_Information_Family(FamilyParameter para, Document familyDoc, FamilyManager manager, All_Data myAll_Data) { string defValue = string.Empty; try { switch (para.StorageType) { case StorageType.Double: if (para.DisplayUnitType.ToString() == "DUT_DECIMAL_DEGREES") { defValue = Math.Round((double)manager.CurrentType.AsDouble(para) * myAll_Data.list_unit_value_data[5], mySource.lam_tron).ToString(); } else { defValue = Math.Round((double)manager.CurrentType.AsDouble(para) * myAll_Data.list_unit_value_data[2], mySource.lam_tron).ToString(); } break; case StorageType.ElementId: ElementId id = manager.CurrentType.AsElementId(para); if (id.IntegerValue >= 0) { defValue = familyDoc.GetElement(id).Name; } else { defValue = id.IntegerValue.ToString(); } break; case StorageType.Integer: if (ParameterType.YesNo == para.Definition.ParameterType) { if (manager.CurrentType.AsInteger(para) == 0) { defValue = "False"; } else { defValue = "True"; } } else { defValue = manager.CurrentType.AsInteger(para).ToString(); } break; case StorageType.String: if (manager.CurrentType.AsString(para) != null) { defValue = manager.CurrentType.AsString(para); } else { defValue = ""; } break; default: defValue = "Unexposed parameter."; break; } } catch (Exception) { } return(defValue); }
//---------------------------------------------------------- public void Get_Level_Bottom(Document doc, ComboBox level_bottom, TextBox elevation_bottom, All_Data myAll_Data) { try { my_level_data_bottom = new ObservableCollection <level_data>(new FilteredElementCollector(doc) .OfClass(typeof(Level)).Cast <Level>() .OrderBy(x => x.Elevation) .ToList().Select(x => new level_data() { level = x, single_value = x.Name, elevation = x.Elevation })); level_bottom.ItemsSource = my_level_data_bottom; if (new FilteredElementCollector(doc).OfClass(typeof(View3D)).Cast <View3D>().Where(x => x.Name == doc.ActiveView.Name).ToList().Count() == 0) { level_bottom.SelectedIndex = my_level_data_bottom.IndexOf(my_level_data_bottom.First(x => x.single_value == doc.ActiveView.get_Parameter(BuiltInParameter.PLAN_VIEW_LEVEL).AsString())); } else { level_bottom.SelectedIndex = 0; } level_data item = (level_data)level_bottom.SelectedItem; elevation_bottom.Text = Math.Round(item.elevation * myAll_Data.list_unit_value_data[2], mySource.lam_tron).ToString(); } catch (Exception ex) { //MessageBox.Show(ex.Message); } }
//---------------------------------------------------------- public void Select_Level_Bottom(ComboBox level_bottom, TextBox elevation_bottom, All_Data myAll_Data, ComboBox type, ListView thong_tin_parameter) { try { level_data item = (level_data)level_bottom.SelectedItem; elevation_bottom.Text = Math.Round(item.elevation * myAll_Data.list_unit_value_data[2], mySource.lam_tron).ToString(); Update_UK_MA(type, myAll_Data, elevation_bottom, thong_tin_parameter); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void Select_Host(UIDocument uidoc, Document doc, Button host, ComboBox level_bottom, ComboBox level_top, TextBox elevation_bottom, TextBox elevation_top, All_Data myAll_Data, ComboBox type, ListView thong_tin_parameter) { try { Selection selection = uidoc.Selection; SelectElementsFilter conduitFilter = new SelectElementsFilter(myAll_Data.list_category_draw_host.ToList()); var element = doc.GetElement(selection.PickObject(ObjectType.Element, conduitFilter, "Please select floor or wall element")); if (element != null) { host.ToolTip = element.Name; host_of_opening = element; double offset_bottom = 0; double offset_top = 0; if (element.Category.Name == myAll_Data.list_category_draw[3]) { offset_bottom = element.get_Parameter(BuiltInParameter.WALL_BASE_OFFSET).AsDouble(); level_bottom.SelectedItem = my_level_data_bottom.First(x => x.single_value == element.get_Parameter(BuiltInParameter.WALL_BASE_CONSTRAINT).AsValueString()); offset_top = element.get_Parameter(BuiltInParameter.WALL_TOP_OFFSET).AsDouble(); level_top.SelectedItem = my_level_data_top.First(x => x.single_value == (doc.GetElement(element.get_Parameter(BuiltInParameter.WALL_HEIGHT_TYPE).AsElementId()).Name)); } else if (element.Category.Name == myAll_Data.list_category_draw[4]) { offset_bottom = element.get_Parameter(BuiltInParameter.FAMILY_BASE_LEVEL_OFFSET_PARAM).AsDouble(); level_bottom.SelectedItem = my_level_data_bottom.First(x => x.single_value == element.get_Parameter(BuiltInParameter.FAMILY_BASE_LEVEL_PARAM).AsValueString()); offset_top = element.get_Parameter(BuiltInParameter.FAMILY_TOP_LEVEL_OFFSET_PARAM).AsDouble(); level_top.SelectedItem = my_level_data_top.First(x => x.single_value == element.get_Parameter(BuiltInParameter.FAMILY_TOP_LEVEL_PARAM).AsValueString()); } else if (element.Category.Name == myAll_Data.list_category_draw[5]) { offset_bottom = element.get_Parameter(BuiltInParameter.STRUCTURAL_ELEVATION_AT_BOTTOM).AsDouble() - (doc.GetElement(element.get_Parameter(BuiltInParameter.INSTANCE_REFERENCE_LEVEL_PARAM).AsElementId()) as Level).Elevation; level_bottom.SelectedItem = my_level_data_bottom.First(x => x.single_value == element.get_Parameter(BuiltInParameter.INSTANCE_REFERENCE_LEVEL_PARAM).AsValueString()); offset_top = element.get_Parameter(BuiltInParameter.STRUCTURAL_ELEVATION_AT_TOP).AsDouble() - (doc.GetElement(element.get_Parameter(BuiltInParameter.INSTANCE_REFERENCE_LEVEL_PARAM).AsElementId()) as Level).Elevation; level_top.SelectedItem = my_level_data_top.First(x => x.single_value == element.get_Parameter(BuiltInParameter.INSTANCE_REFERENCE_LEVEL_PARAM).AsValueString()); } else if (element.Category.Name == myAll_Data.list_category_draw_host[0]) { offset_bottom = element.get_Parameter(BuiltInParameter.STRUCTURAL_ELEVATION_AT_BOTTOM).AsDouble() - (doc.GetElement(element.get_Parameter(BuiltInParameter.LEVEL_PARAM).AsElementId()) as Level).Elevation; level_bottom.SelectedItem = my_level_data_bottom.First(x => x.single_value == element.get_Parameter(BuiltInParameter.LEVEL_PARAM).AsValueString()); offset_top = element.get_Parameter(BuiltInParameter.FLOOR_HEIGHTABOVELEVEL_PARAM).AsDouble(); level_top.SelectedItem = my_level_data_top.First(x => x.single_value == element.get_Parameter(BuiltInParameter.LEVEL_PARAM).AsValueString()); } level_data item_bottom = (level_data)level_bottom.SelectedItem; level_data item_top = (level_data)level_top.SelectedItem; elevation_bottom.Text = Math.Round((item_bottom.elevation + offset_bottom) * myAll_Data.list_unit_value_data[2], mySource.lam_tron).ToString(); elevation_top.Text = Math.Round((item_top.elevation + offset_top) * myAll_Data.list_unit_value_data[2], mySource.lam_tron).ToString(); Update_UK_MA(type, myAll_Data, elevation_bottom, thong_tin_parameter); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
//---------------------------------------------------------- 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); } }
//---------------------------------------------------------- public void Get_Type(Document doc, ComboBox family, ComboBox type, ComboBox material, TextBox search, All_Data myAll_Data) { try { family_data item = (family_data)family.SelectedItem; if (item != null && item.single_value != "") { my_type_data = new ObservableCollection <type_data>(my_family_data .Where(x => x.single_value == item.single_value) .First().types.Select(xx => new type_data() { type = xx, single_value = xx.Name }).OrderBy(x => x.single_value)); } else { my_type_data = new ObservableCollection <type_data>() { new type_data() { type = null, single_value = "" } }; } type.ItemsSource = my_type_data; type.SelectedIndex = 0; CollectionView view_type = (CollectionView)CollectionViewSource.GetDefaultView(type.ItemsSource); view_type.SortDescriptions.Add(new SortDescription("single_value", ListSortDirection.Ascending)); view_type.Filter = Filter_ten_vat_lieu; if (search.Text != "search") { CollectionViewSource.GetDefaultView(type.ItemsSource).Refresh(); type.SelectedItem = my_type_data.First(x => x.single_value.Contains(search.Text)); } type_data item_type = (type_data)type.SelectedItem; if (item_type.type.get_Parameter(BuiltInParameter.STRUCTURAL_MATERIAL_PARAM) != null) { material.SelectedItem = my_material_data.First(x => x.single_value == doc.GetElement(item_type.type.get_Parameter(BuiltInParameter.STRUCTURAL_MATERIAL_PARAM).AsElementId()).Name); material.ToolTip = doc.GetElement(item_type.type.get_Parameter(BuiltInParameter.STRUCTURAL_MATERIAL_PARAM).AsElementId()).Name; } } catch (Exception ex) { //MessageBox.Show(ex.Message); } }
//---------------------------------------------------------- public void Change_Data_Tag(UIApplication uiapp, Document doc, All_Data myAll_Data) { try { var builtin_category = Enum.GetValues(typeof(BuiltInCategory)).Cast <BuiltInCategory>().ToList(); var categories = doc.Settings.Categories; List <BuiltInCategory> list_builtin = new List <BuiltInCategory>(); foreach (string category in myAll_Data.list_category_tag) { foreach (BuiltInCategory buildCategory in builtin_category) { try { if (categories.get_Item(buildCategory) != null && categories.get_Item(buildCategory).Name == category) { list_builtin.Add(buildCategory); break; } } catch (Exception) { } } } ElementMulticategoryFilter filter_category = new ElementMulticategoryFilter(list_builtin); List <Element> list_tag = new FilteredElementCollector(doc) .WherePasses(filter_category) .WhereElementIsNotElementType() .ToList(); foreach (FamilyInstance familyInstance in list_tag) { Element host_of_opening = familyInstance.Host; if (host_of_opening != null) { if (host_of_opening.Category.Name == myAll_Data.list_category_draw_host[0]) { } else if (host_of_opening.Category.Name == myAll_Data.list_category_draw_host[1]) { Level level = doc.GetElement(familyInstance.get_Parameter(BuiltInParameter.FAMILY_LEVEL_PARAM).AsElementId()) as Level; double offset_bottom = level.Elevation + familyInstance.get_Parameter(BuiltInParameter.INSTANCE_ELEVATION_PARAM).AsDouble(); if (familyInstance.LookupParameter(myAll_Data.list_parameter_tag[4]) != null) { familyInstance.LookupParameter(myAll_Data.list_parameter_tag[4]).Set(offset_bottom); } double offset = 0; if (familyInstance.get_Parameter(BuiltInParameter.FAMILY_ROUGH_HEIGHT_PARAM) != null) { offset = familyInstance.get_Parameter(BuiltInParameter.FAMILY_ROUGH_HEIGHT_PARAM).AsDouble(); } double offset_uk = offset_bottom + offset; if (familyInstance.LookupParameter(myAll_Data.list_parameter_tag[1]) != null) { familyInstance.LookupParameter(myAll_Data.list_parameter_tag[1]).Set(offset_uk); } if (familyInstance.LookupParameter(myAll_Data.list_parameter_tag[2]) != null) { familyInstance.LookupParameter(myAll_Data.list_parameter_tag[2]).Set(offset_uk); } if (familyInstance.LookupParameter(myAll_Data.list_parameter_tag[3]) != null) { familyInstance.LookupParameter(myAll_Data.list_parameter_tag[3]).Set(offset_uk); } } else { if (familyInstance.get_Parameter(BuiltInParameter.FAMILY_LEVEL_PARAM) != null && familyInstance.get_Parameter(BuiltInParameter.FAMILY_LEVEL_PARAM).AsElementId().IntegerValue != -1) { Level level = doc.GetElement(familyInstance.get_Parameter(BuiltInParameter.FAMILY_LEVEL_PARAM).AsElementId()) as Level; double offset_bottom = level.Elevation + familyInstance.get_Parameter(BuiltInParameter.INSTANCE_ELEVATION_PARAM).AsDouble(); if (familyInstance.LookupParameter(myAll_Data.list_parameter_tag[1]) != null) { familyInstance.LookupParameter(myAll_Data.list_parameter_tag[1]).Set(offset_bottom); } if (familyInstance.LookupParameter(myAll_Data.list_parameter_tag[2]) != null) { familyInstance.LookupParameter(myAll_Data.list_parameter_tag[2]).Set(offset_bottom); } if (familyInstance.LookupParameter(myAll_Data.list_parameter_tag[3]) != null) { familyInstance.LookupParameter(myAll_Data.list_parameter_tag[3]).Set(offset_bottom); } } else if (familyInstance.get_Parameter(BuiltInParameter.INSTANCE_SCHEDULE_ONLY_LEVEL_PARAM) != null && familyInstance.get_Parameter(BuiltInParameter.INSTANCE_SCHEDULE_ONLY_LEVEL_PARAM).AsElementId().IntegerValue != -1) { Level level = doc.GetElement(familyInstance.get_Parameter(BuiltInParameter.INSTANCE_SCHEDULE_ONLY_LEVEL_PARAM).AsElementId()) as Level; double offset_bottom = level.Elevation + familyInstance.get_Parameter(BuiltInParameter.INSTANCE_ELEVATION_PARAM).AsDouble(); if (familyInstance.LookupParameter(myAll_Data.list_parameter_tag[1]) != null) { familyInstance.LookupParameter(myAll_Data.list_parameter_tag[1]).Set(offset_bottom); } if (familyInstance.LookupParameter(myAll_Data.list_parameter_tag[2]) != null) { familyInstance.LookupParameter(myAll_Data.list_parameter_tag[2]).Set(offset_bottom); } if (familyInstance.LookupParameter(myAll_Data.list_parameter_tag[3]) != null) { familyInstance.LookupParameter(myAll_Data.list_parameter_tag[3]).Set(offset_bottom); } } } } else { if (familyInstance.get_Parameter(BuiltInParameter.FAMILY_LEVEL_PARAM) != null && familyInstance.get_Parameter(BuiltInParameter.FAMILY_LEVEL_PARAM).AsElementId().IntegerValue != -1) { Level level = doc.GetElement(familyInstance.get_Parameter(BuiltInParameter.FAMILY_LEVEL_PARAM).AsElementId()) as Level; double offset_bottom = level.Elevation + familyInstance.get_Parameter(BuiltInParameter.INSTANCE_ELEVATION_PARAM).AsDouble(); if (familyInstance.LookupParameter(myAll_Data.list_parameter_tag[1]) != null) { familyInstance.LookupParameter(myAll_Data.list_parameter_tag[1]).Set(offset_bottom); } if (familyInstance.LookupParameter(myAll_Data.list_parameter_tag[2]) != null) { familyInstance.LookupParameter(myAll_Data.list_parameter_tag[2]).Set(offset_bottom); } if (familyInstance.LookupParameter(myAll_Data.list_parameter_tag[3]) != null) { familyInstance.LookupParameter(myAll_Data.list_parameter_tag[3]).Set(offset_bottom); } } else if (familyInstance.get_Parameter(BuiltInParameter.INSTANCE_SCHEDULE_ONLY_LEVEL_PARAM) != null && familyInstance.get_Parameter(BuiltInParameter.INSTANCE_SCHEDULE_ONLY_LEVEL_PARAM).AsElementId().IntegerValue != -1) { Level level = doc.GetElement(familyInstance.get_Parameter(BuiltInParameter.INSTANCE_SCHEDULE_ONLY_LEVEL_PARAM).AsElementId()) as Level; double offset_bottom = level.Elevation + familyInstance.get_Parameter(BuiltInParameter.INSTANCE_ELEVATION_PARAM).AsDouble(); if (familyInstance.LookupParameter(myAll_Data.list_parameter_tag[1]) != null) { familyInstance.LookupParameter(myAll_Data.list_parameter_tag[1]).Set(offset_bottom); } if (familyInstance.LookupParameter(myAll_Data.list_parameter_tag[2]) != null) { familyInstance.LookupParameter(myAll_Data.list_parameter_tag[2]).Set(offset_bottom); } if (familyInstance.LookupParameter(myAll_Data.list_parameter_tag[3]) != null) { familyInstance.LookupParameter(myAll_Data.list_parameter_tag[3]).Set(offset_bottom); } } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
//---------------------------------------------------------- public All_Data Get_Data_All(string path) { All_Data myAll_Data = new All_Data(); try { List <string> du_lieu = File.ReadAllLines(path).ToList(); myAll_Data = new All_Data() { list_path_image_data = new ObservableCollection <list_image>(Get_Data_List(du_lieu, "path_image").Select(x => new list_image() { image_name = x.Split('\t')[2], image_path = x.Split('\t')[3] })), list_unit_value_data = new ObservableCollection <double>(Get_Data_List(du_lieu, "unit_value").Select(x => Convert.ToDouble(x.Split('\t')[2]))), list_color_UI_data = new ObservableCollection <Brush>(Get_Data_List(du_lieu, "color_UI").Select(x => (SolidColorBrush) new BrushConverter().ConvertFromString(x.Split('\t')[2]))), list_procedure_data = new ObservableCollection <list_procedure>(Get_Data_List(du_lieu, "sp_quantity").Select(x => new list_procedure() { procedure_name = x.Split('\t')[2], procedure_para = x.Split('\t')[3] })), list_path_foder_data = new ObservableCollection <string>(Get_Data_List(du_lieu, "path_foder").Select(x => x.Split('\t')[2])), list_path_connect_SQL_data = new ObservableCollection <string>(Get_Data_List(du_lieu, "path_connect_SQL").Select(x => x.Split('\t')[2])), list_material_para_data = new ObservableCollection <list_material_para>(Get_Data_List(du_lieu, "material_parameter").Select(x => new list_material_para() { material_para_guid = x.Split('\t')[2], material_para_name = x.Split('\t')[3] })), list_mct_descipline_data = new ObservableCollection <list_mct_descipline>(Get_Data_List(du_lieu, "mct_descipline").Select(x => new list_mct_descipline() { mct = x.Split('\t')[2], descipline = x.Split('\t')[3] })), list_parameter_share_data = new ObservableCollection <string>(Get_Data_List(du_lieu, "parameter_share").Select(x => x.Split('\t')[2])), list_category_draw = new ObservableCollection <string>(Get_Data_List(du_lieu, "list_category_draw").Select(x => x.Split('\t')[2])), list_category_draw_host = new ObservableCollection <string>(Get_Data_List(du_lieu, "list_category_draw_host").Select(x => x.Split('\t')[2])), list_parameter_tag = new ObservableCollection <string>(Get_Data_List(du_lieu, "list_parameter_tag").Select(x => x.Split('\t')[2])), list_parameter_framing = new ObservableCollection <string>(Get_Data_List(du_lieu, "list_parameter_framing").Select(x => x.Split('\t')[2])), list_parameter_column = new ObservableCollection <string>(Get_Data_List(du_lieu, "list_parameter_column").Select(x => x.Split('\t')[2])), list_parameter_opening = new ObservableCollection <string>(Get_Data_List(du_lieu, "list_parameter_opening").Select(x => x.Split('\t')[2])), list_category_tag = new ObservableCollection <string>(Get_Data_List(du_lieu, "list_category_tag").Select(x => x.Split('\t')[2])) }; } catch (Exception ex) { MessageBox.Show(ex.Message); } return(myAll_Data); }
//---------------------------------------------------------- public void Select_Update(UIDocument uidoc, Document doc, Button host, ComboBox level_bottom, ComboBox level_top, TextBox elevation_bottom, TextBox elevation_top, ComboBox material, TextBox search, ListView thong_tin_parameter, ComboBox category, ComboBox family, ComboBox type, All_Data myAll_Data) { try { Selection selection = uidoc.Selection; SelectElementsFilter conduitFilter = new SelectElementsFilter(myAll_Data.list_category_draw.ToList()); element_update = doc.GetElement(selection.PickObject(ObjectType.Element, conduitFilter, "Please select element update")); if (element_update != null) { selection.SetElementIds(new List <ElementId>() { element_update.Id }); host_of_opening = null; if (new FilteredElementCollector(doc).OfClass(typeof(FamilySymbol)).Where(x => x.Name == element_update.get_Parameter(BuiltInParameter.ELEM_TYPE_PARAM).AsValueString()).ToList().Count() > 0) { FamilyInstance familyInstance = element_update as FamilyInstance; if (familyInstance.Host != null) { host.ToolTip = familyInstance.Host.Name; host_of_opening = familyInstance.Host; } } double offset_bottom = 0; double offset_top = 0; if (element_update.Category.Name == myAll_Data.list_category_draw[3]) { offset_bottom = element_update.get_Parameter(BuiltInParameter.WALL_BASE_OFFSET).AsDouble(); level_bottom.SelectedItem = my_level_data_bottom.First(x => x.single_value == element_update.get_Parameter(BuiltInParameter.WALL_BASE_CONSTRAINT).AsValueString()); offset_top = element_update.get_Parameter(BuiltInParameter.WALL_TOP_OFFSET).AsDouble(); level_top.SelectedItem = my_level_data_top.First(x => x.single_value == (doc.GetElement(element_update.get_Parameter(BuiltInParameter.WALL_HEIGHT_TYPE).AsElementId()).Name)); } else if (element_update.Category.Name == myAll_Data.list_category_draw[4]) { offset_bottom = element_update.get_Parameter(BuiltInParameter.FAMILY_BASE_LEVEL_OFFSET_PARAM).AsDouble(); level_bottom.SelectedItem = my_level_data_bottom.First(x => x.single_value == element_update.get_Parameter(BuiltInParameter.FAMILY_BASE_LEVEL_PARAM).AsValueString()); offset_top = element_update.get_Parameter(BuiltInParameter.FAMILY_TOP_LEVEL_OFFSET_PARAM).AsDouble(); level_top.SelectedItem = my_level_data_top.First(x => x.single_value == element_update.get_Parameter(BuiltInParameter.FAMILY_TOP_LEVEL_PARAM).AsValueString()); } else if (element_update.Category.Name == myAll_Data.list_category_draw[5]) { offset_bottom = element_update.get_Parameter(BuiltInParameter.STRUCTURAL_ELEVATION_AT_BOTTOM).AsDouble() - (doc.GetElement(element_update.get_Parameter(BuiltInParameter.INSTANCE_REFERENCE_LEVEL_PARAM).AsElementId()) as Level).Elevation; level_bottom.SelectedItem = my_level_data_bottom.First(x => x.single_value == element_update.get_Parameter(BuiltInParameter.INSTANCE_REFERENCE_LEVEL_PARAM).AsValueString()); offset_top = element_update.get_Parameter(BuiltInParameter.STRUCTURAL_ELEVATION_AT_TOP).AsDouble() - (doc.GetElement(element_update.get_Parameter(BuiltInParameter.INSTANCE_REFERENCE_LEVEL_PARAM).AsElementId()) as Level).Elevation; level_top.SelectedItem = my_level_data_top.First(x => x.single_value == element_update.get_Parameter(BuiltInParameter.INSTANCE_REFERENCE_LEVEL_PARAM).AsValueString()); } else if (element_update.Category.Name == myAll_Data.list_category_draw_host[0]) { offset_bottom = element_update.get_Parameter(BuiltInParameter.STRUCTURAL_ELEVATION_AT_BOTTOM).AsDouble() - (doc.GetElement(element_update.get_Parameter(BuiltInParameter.LEVEL_PARAM).AsElementId()) as Level).Elevation; level_bottom.SelectedItem = my_level_data_bottom.First(x => x.single_value == element_update.get_Parameter(BuiltInParameter.LEVEL_PARAM).AsValueString()); offset_top = element_update.get_Parameter(BuiltInParameter.FLOOR_HEIGHTABOVELEVEL_PARAM).AsDouble(); level_top.SelectedItem = my_level_data_top.First(x => x.single_value == element_update.get_Parameter(BuiltInParameter.LEVEL_PARAM).AsValueString()); } else { if (host_of_opening != null) { if (host_of_opening.Category.Name == myAll_Data.list_category_draw_host[0]) { offset_bottom = 0; level_bottom.SelectedItem = my_level_data_bottom.First(x => x.single_value == element_update.get_Parameter(BuiltInParameter.FAMILY_LEVEL_PARAM).AsValueString()); offset_top = 0; level_top.SelectedItem = my_level_data_top.First(x => x.single_value == element_update.get_Parameter(BuiltInParameter.FAMILY_LEVEL_PARAM).AsValueString()); } else if (host_of_opening.Category.Name == myAll_Data.list_category_draw_host[1]) { offset_bottom = element_update.get_Parameter(BuiltInParameter.INSTANCE_ELEVATION_PARAM).AsDouble(); level_bottom.SelectedItem = my_level_data_bottom.First(x => x.single_value == element_update.get_Parameter(BuiltInParameter.FAMILY_LEVEL_PARAM).AsValueString()); // read-only offset_top = 0; level_top.SelectedIndex = my_level_data_top.IndexOf(my_level_data_top.First(x => x.single_value == element_update.get_Parameter(BuiltInParameter.FAMILY_LEVEL_PARAM).AsValueString())) + 1; } else { if (element_update.get_Parameter(BuiltInParameter.FAMILY_LEVEL_PARAM) != null && element_update.get_Parameter(BuiltInParameter.FAMILY_LEVEL_PARAM).AsElementId().IntegerValue != -1) { offset_bottom = element_update.get_Parameter(BuiltInParameter.INSTANCE_ELEVATION_PARAM).AsDouble(); level_bottom.SelectedItem = my_level_data_bottom.First(x => x.single_value == element_update.get_Parameter(BuiltInParameter.FAMILY_LEVEL_PARAM).AsValueString()); // read-only offset_top = 0; level_top.SelectedIndex = my_level_data_top.IndexOf(my_level_data_top.First(x => x.single_value == element_update.get_Parameter(BuiltInParameter.FAMILY_LEVEL_PARAM).AsValueString())) + 1; } else if (element_update.get_Parameter(BuiltInParameter.INSTANCE_SCHEDULE_ONLY_LEVEL_PARAM) != null && element_update.get_Parameter(BuiltInParameter.INSTANCE_SCHEDULE_ONLY_LEVEL_PARAM).AsElementId().IntegerValue != -1) { offset_bottom = element_update.get_Parameter(BuiltInParameter.INSTANCE_ELEVATION_PARAM).AsDouble(); level_bottom.SelectedItem = my_level_data_bottom.First(x => x.single_value == element_update.get_Parameter(BuiltInParameter.INSTANCE_SCHEDULE_ONLY_LEVEL_PARAM).AsValueString()); // read-only offset_top = 0; level_top.SelectedIndex = my_level_data_top.IndexOf(my_level_data_top.First(x => x.single_value == element_update.get_Parameter(BuiltInParameter.INSTANCE_SCHEDULE_ONLY_LEVEL_PARAM).AsValueString())) + 1; } } } else { if (element_update.get_Parameter(BuiltInParameter.FAMILY_LEVEL_PARAM) != null && element_update.get_Parameter(BuiltInParameter.FAMILY_LEVEL_PARAM).AsElementId().IntegerValue != -1) { offset_bottom = element_update.get_Parameter(BuiltInParameter.INSTANCE_ELEVATION_PARAM).AsDouble(); level_bottom.SelectedItem = my_level_data_bottom.First(x => x.single_value == element_update.get_Parameter(BuiltInParameter.FAMILY_LEVEL_PARAM).AsValueString()); // read-only offset_top = 0; level_top.SelectedIndex = my_level_data_top.IndexOf(my_level_data_top.First(x => x.single_value == element_update.get_Parameter(BuiltInParameter.FAMILY_LEVEL_PARAM).AsValueString())) + 1; } else if (element_update.get_Parameter(BuiltInParameter.INSTANCE_SCHEDULE_ONLY_LEVEL_PARAM) != null && element_update.get_Parameter(BuiltInParameter.INSTANCE_SCHEDULE_ONLY_LEVEL_PARAM).AsElementId().IntegerValue != -1) { offset_bottom = element_update.get_Parameter(BuiltInParameter.INSTANCE_ELEVATION_PARAM).AsDouble(); level_bottom.SelectedItem = my_level_data_bottom.First(x => x.single_value == element_update.get_Parameter(BuiltInParameter.INSTANCE_SCHEDULE_ONLY_LEVEL_PARAM).AsValueString()); // read-only offset_top = 0; level_top.SelectedIndex = my_level_data_top.IndexOf(my_level_data_top.First(x => x.single_value == element_update.get_Parameter(BuiltInParameter.INSTANCE_SCHEDULE_ONLY_LEVEL_PARAM).AsValueString())) + 1; } } } level_data item_bottom = (level_data)level_bottom.SelectedItem; level_data item_top = (level_data)level_top.SelectedItem; elevation_bottom.Text = Math.Round((item_bottom.elevation + offset_bottom) * myAll_Data.list_unit_value_data[2], mySource.lam_tron).ToString(); elevation_top.Text = Math.Round((item_top.elevation + offset_top) * myAll_Data.list_unit_value_data[2], mySource.lam_tron).ToString(); //------------------------------------------------------------------------------------------------------------------------------------------------ category.SelectedItem = my_category_data.First(x => x.single_value == element_update.Category.Name); Get_Family(doc, category, family, myAll_Data); family.SelectedItem = my_family_data.First(x => x.single_value == element_update.get_Parameter(BuiltInParameter.ELEM_FAMILY_PARAM).AsValueString()); Get_Type(doc, family, type, material, search, myAll_Data); type.SelectedItem = my_type_data.First(x => x.single_value == element_update.get_Parameter(BuiltInParameter.ELEM_TYPE_PARAM).AsValueString()); type_data item_type = (type_data)type.SelectedItem; if (item_type.type.get_Parameter(BuiltInParameter.STRUCTURAL_MATERIAL_PARAM) != null) { material.SelectedItem = my_material_data.First(x => x.single_value == doc.GetElement(item_type.type.get_Parameter(BuiltInParameter.STRUCTURAL_MATERIAL_PARAM).AsElementId()).Name); material.ToolTip = doc.GetElement(item_type.type.get_Parameter(BuiltInParameter.STRUCTURAL_MATERIAL_PARAM).AsElementId()).Name; } Get_Parameter(element_update, doc, category, family, type, thong_tin_parameter, myAll_Data); Update_UK_MA(type, myAll_Data, elevation_bottom, thong_tin_parameter); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }