示例#1
0
        //----------------------------------------------------------
        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);
            }
        }
示例#2
0
        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);
            }
        }