Exemplo n.º 1
0
        private void Select_Host(object sender, RoutedEventArgs e)
        {
            try
            {
                Selection            selection     = uidoc.Selection;
                SelectElementsFilter conduitFilter = new SelectElementsFilter(mySource.my_select_host_filter);
                var element = doc.GetElement(selection.PickObject(ObjectType.Element, conduitFilter, "Please select floor or wall element"));
                if (element != null)
                {
                    host.Content = element.Name;
                    host.ToolTip = element.UniqueId;

                    host_of_opening    = element;
                    level.SelectedItem = my_level_data.First(x => x.single_value == doc.GetElement(element.LevelId).Name);
                    level.IsEnabled    = true;

                    level_data item = (level_data)level.SelectedItem;
                    elevation.Text = Math.Round(item.elevation * myAll_Data.list_unit_value_data[2], mySource.lam_tron).ToString();

                    Update_UK_MA();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 2
0
        //--------------------------------------------------------------------------------------------------------------------------------------------------------------
        private void Select_Level(object sender, EventArgs e)
        {
            try
            {
                level_data item = (level_data)level.SelectedItem;
                elevation.Text = Math.Round(item.elevation * myAll_Data.list_unit_value_data[2], mySource.lam_tron).ToString();

                Update_UK_MA();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 3
0
        //----------------------------------------------------------
        public void Update_UK_MA()
        {
            try
            {
                level_data item_level = (level_data)level.SelectedItem;
                type_data  item_type  = (type_data)type.SelectedItem;
                if (door.IsChecked == true)
                {
                    my_parameter_data.Where(x => x.parameter_name == mySource.para_name[2] || x.parameter_name == mySource.para_name[4])
                    .ToList().ForEach(x => x.parameter_value = (Convert.ToDouble(elevation.Text) + (item_type.type.get_Parameter(BuiltInParameter.FAMILY_HEIGHT_PARAM).AsDouble()) * myAll_Data.list_unit_value_data[2]).ToString());
                }
                else
                {
                    my_parameter_data.Where(x => x.parameter_name == mySource.para_name[2] || x.parameter_name == mySource.para_name[3])
                    .ToList().ForEach(x => x.parameter_value = elevation.Text);
                }

                thong_tin_parameter.Items.Refresh();
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 4
0
        //----------------------------------------------------------
        public void Get_Level()
        {
            try
            {
                my_level_data = 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.ItemsSource   = my_level_data;
                level.SelectedIndex = 0;
                level_data item = (level_data)level.SelectedItem;
                elevation.Text = Math.Round(item.elevation * myAll_Data.list_unit_value_data[2], mySource.lam_tron).ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 5
0
        //--------------------------------------------------------------------------------------------------------------------------------------------------------------
        private void Select_Element_Update(object sender, RoutedEventArgs e)
        {
            try
            {
                Selection            selection     = uidoc.Selection;
                SelectElementsFilter conduitFilter = new SelectElementsFilter(mySource.my_select_filter);
                element = doc.GetElement(selection.PickObject(ObjectType.Element, conduitFilter, "Please select opening element")) as FamilyInstance;
                if (element != null)
                {
                    host.Content = element.Host.Name;
                    host.ToolTip = element.Host.UniqueId;

                    host_of_opening = element.Host;
                    if (new FilteredElementCollector(doc).OfClass(typeof(FamilySymbol)).Where(x => x.Name == host_of_opening.Name).ToList().Count() > 0)
                    {
                        level.SelectedItem = my_level_data.First(x => x.single_value == element.get_Parameter(BuiltInParameter.INSTANCE_SCHEDULE_ONLY_LEVEL_PARAM).AsValueString());
                        if (element.get_Parameter(BuiltInParameter.INSTANCE_SCHEDULE_ONLY_LEVEL_PARAM).IsReadOnly == true)
                        {
                            level.IsEnabled = false;
                        }
                        else
                        {
                            level.IsEnabled = true;
                        }
                    }
                    else
                    {
                        level.SelectedItem = my_level_data.First(x => x.single_value == doc.GetElement(element.LevelId).Name);
                        if (element.get_Parameter(BuiltInParameter.FAMILY_LEVEL_PARAM).IsReadOnly == true)
                        {
                            level.IsEnabled = false;
                        }
                        else
                        {
                            level.IsEnabled = true;
                        }
                    }

                    level_data item = (level_data)level.SelectedItem;
                    if (element.Category.Name == "Doors")
                    {
                        elevation.Text = Math.Round((item.elevation + element.get_Parameter(BuiltInParameter.INSTANCE_SILL_HEIGHT_PARAM).AsDouble()) * myAll_Data.list_unit_value_data[2], mySource.lam_tron).ToString();
                        door.IsChecked = true;
                    }
                    else
                    {
                        elevation.Text          = Math.Round((item.elevation + element.get_Parameter(BuiltInParameter.INSTANCE_ELEVATION_PARAM).AsDouble()) * myAll_Data.list_unit_value_data[2], mySource.lam_tron).ToString();
                        generic_model.IsChecked = true;
                    }

                    Get_Family();
                    family.SelectedItem = my_family_data.First(x => x.single_value == element.get_Parameter(BuiltInParameter.ELEM_FAMILY_PARAM).AsValueString());

                    Get_Type();
                    type.SelectedItem = my_type_data.First(x => x.single_value == element.get_Parameter(BuiltInParameter.ELEM_TYPE_PARAM).AsValueString());

                    Get_Parameter(element);

                    Update_UK_MA();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 6
0
        //----------------------------------------------------------
        public string Draw_By_Revit(UIApplication uiapp, Document doc)
        {
            string result = "F";

            try
            {
                if (data_point.Count() > 0)
                {
                    level_data  item_level  = (level_data)level.SelectedItem;
                    family_data item_family = (family_data)family.SelectedItem;
                    type_data   item_type   = (type_data)type.SelectedItem;

                    XYZ center = new XYZ();
                    if (data_point[0].Count() == 2)
                    {
                        center = (data_point[0][0] + data_point[0][1]) / 2;
                    }
                    else
                    {
                        center = data_point[0][0];
                    }
                    FamilySymbol familySymbol  = item_type.type as FamilySymbol;
                    Level        level_opening = item_level.level;
                    if (familySymbol.IsActive == false)
                    {
                        familySymbol.Activate();
                    }

                    var instance = doc.Create.NewFamilyInstance(center, familySymbol, host_of_opening, level_opening, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);

                    double elevation_value = Convert.ToDouble(elevation.Text) / myAll_Data.list_unit_value_data[2] - item_level.elevation;
                    if (new FilteredElementCollector(doc).OfClass(typeof(FamilySymbol)).Where(x => x.Name == host_of_opening.Name).ToList().Count() == 0 && host_of_opening.Category.Name != "Walls")
                    {
                    }
                    else
                    {
                        if (door.IsChecked == true)
                        {
                            instance.get_Parameter(BuiltInParameter.INSTANCE_SILL_HEIGHT_PARAM).Set(elevation_value);
                            if (instance.LookupParameter(mySource.para_name[0]) != null)
                            {
                                instance.LookupParameter(mySource.para_name[0]).Set(Convert.ToDouble(elevation.Text) / myAll_Data.list_unit_value_data[2]);
                            }
                            if (instance.LookupParameter(mySource.para_name[1]) != null)
                            {
                                instance.LookupParameter(mySource.para_name[1]).Set(0);
                            }
                        }
                        else
                        {
                            if (host_of_opening.Category.Name != "Walls")
                            {
                                instance.get_Parameter(BuiltInParameter.INSTANCE_SCHEDULE_ONLY_LEVEL_PARAM).Set(item_level.level.Id);
                            }
                            instance.get_Parameter(BuiltInParameter.INSTANCE_ELEVATION_PARAM).Set(elevation_value);
                        }
                    }

                    foreach (parameter_data data in my_parameter_data)
                    {
                        if (instance.LookupParameter(data.parameter_name).IsReadOnly == false)
                        {
                            if (data.parameter_value == "True")
                            {
                                instance.LookupParameter(data.parameter_name).Set(1);
                            }
                            else if (data.parameter_value == "False")
                            {
                                instance.LookupParameter(data.parameter_name).Set(0);
                            }
                            else
                            {
                                instance.LookupParameter(data.parameter_name).Set(Convert.ToDouble(data.parameter_value) / myAll_Data.list_unit_value_data[2]);
                            }
                        }
                    }
                }


                result = "S";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return(result);
        }
Exemplo n.º 7
0
        //----------------------------------------------------------
        public string Update_By_Revit(UIApplication uiapp, Document doc)
        {
            string result = "F";

            try
            {
                level_data   item_level   = (level_data)level.SelectedItem;
                family_data  item_family  = (family_data)family.SelectedItem;
                type_data    item_type    = (type_data)type.SelectedItem;
                FamilySymbol familySymbol = item_type.type as FamilySymbol;
                if (familySymbol.IsActive == false)
                {
                    familySymbol.Activate();
                }

                if (element.Symbol != familySymbol)
                {
                    element.Symbol = familySymbol;
                }

                double elevation_value = Convert.ToDouble(elevation.Text) / myAll_Data.list_unit_value_data[2] - item_level.elevation;
                if (new FilteredElementCollector(doc).OfClass(typeof(FamilySymbol)).Where(x => x.Name == host_of_opening.Name).ToList().Count() == 0 && host_of_opening.Category.Name != "Walls")
                {
                }
                else
                {
                    if (element.Category.Name == "Doors")
                    {
                        element.get_Parameter(BuiltInParameter.INSTANCE_SILL_HEIGHT_PARAM).Set(elevation_value);
                        if (element.LookupParameter(mySource.para_name[0]) != null)
                        {
                            element.LookupParameter(mySource.para_name[0]).Set(Convert.ToDouble(elevation.Text) / myAll_Data.list_unit_value_data[2]);
                        }
                        if (element.LookupParameter(mySource.para_name[1]) != null)
                        {
                            element.LookupParameter(mySource.para_name[1]).Set(0);
                        }
                    }
                    else
                    {
                        if (host_of_opening.Category.Name != "Walls")
                        {
                            element.get_Parameter(BuiltInParameter.INSTANCE_SCHEDULE_ONLY_LEVEL_PARAM).Set(item_level.level.Id);
                        }
                        element.get_Parameter(BuiltInParameter.INSTANCE_ELEVATION_PARAM).Set(elevation_value);
                    }
                }

                foreach (parameter_data data in my_parameter_data)
                {
                    if (data.parameter_value == "True")
                    {
                        element.LookupParameter(data.parameter_name).Set(1);
                    }
                    else if (data.parameter_value == "False")
                    {
                        element.LookupParameter(data.parameter_name).Set(0);
                    }
                    else
                    {
                        element.LookupParameter(data.parameter_name).Set(Convert.ToDouble(data.parameter_value) / myAll_Data.list_unit_value_data[2]);
                    }
                }

                if (data_point.Count() > 0)
                {
                    XYZ center = new XYZ();
                    if (data_point[0].Count() == 2)
                    {
                        center = (data_point[0][0] + data_point[0][1]) / 2;
                    }
                    else
                    {
                        center = data_point[0][0];
                    }

                    LocationPoint location       = element.Location as LocationPoint;
                    XYZ           location_point = location.Point;

                    XYZ move_point = new XYZ(center.X - location_point.X, center.Y - location_point.Y, 0);

                    ElementTransformUtils.MoveElement(doc, element.Id, move_point);
                }

                result = "S";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return(result);
        }