コード例 #1
0
        private void comboBoxRevit_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                if (null != comboBoxRevit.SelectedItem)
                {
                    CategoryProperties         cp        = (CategoryProperties)comboBoxRevit.SelectedItem;
                    List <ParameterProperties> paramList = cp.ParamDictionary.Values.ToList();
                    paramList = paramList.OrderBy(o => o.ParameterName).ToList();
                    dataGridRevit.ItemsSource = null;
                    dataGridRevit.ItemsSource = paramList;

                    /*
                     * var parameters = from param in cp.ParamDictionary.Values where param.IsReadOnly == false select param;
                     * if (parameters.Count() > 0)
                     * {
                     *  List<ParameterProperties> paramList = parameters.OrderBy(o => o.ParameterName).ToList();
                     *  dataGridRevit.ItemsSource = null;
                     *  dataGridRevit.ItemsSource = paramList;
                     * }*/
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to select Revit Category.\n" + ex.Message, "Revit Category Selection Changed.", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
コード例 #2
0
        private static ParameterMapProperties GetParameterMapProperties(Document doc, Entity entity)
        {
            ParameterMapProperties pmp = null;

            try
            {
                string spatialCategoryName  = entity.Get <string>(m_schema.GetField(s_SpatialCategory));
                string spatialParameterName = entity.Get <string>(m_schema.GetField(s_SpatialParameter));
                string revitCategoryName    = entity.Get <string>(m_schema.GetField(s_RevitCategory));
                string revitParameterName   = entity.Get <string>(m_schema.GetField(s_RevitParameter));

                Category spatialCategory = doc.Settings.Categories.get_Item(spatialCategoryName);
                Category revitCategory   = doc.Settings.Categories.get_Item(revitCategoryName);
                if (null != spatialCategory && null != revitCategory)
                {
                    CategoryProperties scp = new CategoryProperties(spatialCategory);
                    CategoryProperties rcp = new CategoryProperties(revitCategory);

                    ParameterProperties spp = new ParameterProperties(spatialParameterName);
                    ParameterProperties rpp = new ParameterProperties(revitParameterName);

                    pmp = new ParameterMapProperties(spp, rpp, scp, rcp);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to get parameter map properties.\n" + ex.Message, "Get Parameter Map Properties", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
            return(pmp);
        }
コード例 #3
0
        public ParameterMapProperties(ParameterProperties spp, ParameterProperties rpp, CategoryProperties scp, CategoryProperties rcp)
        {
            spatialParameter = spp;
            spatialParamName = spp.ParameterName;

            revitParameter = rpp;
            revitParamName = rpp.ParameterName;

            spatialCategory = scp;
            spatialCatName  = scp.CategoryName;

            revitCategory = rcp;
            revitCatName  = rcp.CategoryName;
        }
コード例 #4
0
        private void buttonAdd_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (null != dataGridSpatial.SelectedItem && null != dataGridRevit.SelectedItem)
                {
                    ParameterProperties spp = (ParameterProperties)dataGridSpatial.SelectedItem;
                    ParameterProperties rpp = (ParameterProperties)dataGridRevit.SelectedItem;
                    if (rpp.IsSelectable)
                    {
                        CategoryProperties scp = (CategoryProperties)comboBoxSpace.SelectedItem;
                        CategoryProperties rcp = (CategoryProperties)comboBoxRevit.SelectedItem;

                        ParameterMapProperties pmp = new ParameterMapProperties(spp, rpp, scp, rcp);

                        var properties = from property in parameterMapList
                                         where property.SpatialCatName == scp.CategoryName && property.RevitCatName == rcp.CategoryName &&
                                         property.SpatialParamName == spp.ParameterName && property.RevitParamName == rpp.ParameterName
                                         select property;
                        if (properties.Count() == 0)
                        {
                            parameterMapList.Add(pmp);

                            dataGridParamMap.ItemsSource = null;
                            dataGridParamMap.ItemsSource = parameterMapList;
                        }
                        else
                        {
                            MessageBox.Show("The selected parameter map already exist in the selsction.\nPlease select different categories and paraemters.", "Existing Maps", MessageBoxButton.OK, MessageBoxImage.Warning);
                        }
                    }
                    else
                    {
                        MessageBox.Show("The storage types do not match between spatial and Revit parameters.\nPlease select a valid parameter.", "Storage Type Mismatched", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                }
                else
                {
                    MessageBox.Show("Please select a pair of parameter from a spatial category and a Revit category.", "Parameter Not Selected", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to add links.\n" + ex.Message, "Add Parameter Maps", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
コード例 #5
0
 private void comboBoxSpace_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         if (null != comboBoxSpace.SelectedItem)
         {
             CategoryProperties         cp        = (CategoryProperties)comboBoxSpace.SelectedItem;
             List <ParameterProperties> paramList = cp.ParamDictionary.Values.ToList();
             paramList = paramList.OrderBy(o => o.ParameterName).ToList();
             dataGridSpatial.ItemsSource = null;
             dataGridSpatial.ItemsSource = paramList;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Failed to select spatial category.\n" + ex.Message, "Spatial Category Selection Changed", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
 }
コード例 #6
0
        private void DisplayCategories()
        {
            try
            {
                Categories categories = m_doc.Settings.Categories;
                List <CategoryProperties> spaceCategoryList = new List <CategoryProperties>();
                BuiltInCategory           bltRoom           = BuiltInCategory.OST_Rooms;
                Category roomCat = categories.get_Item(bltRoom);
                if (null != roomCat)
                {
                    CategoryProperties cp = new CategoryProperties(roomCat);
                    cp.ParamDictionary = GetParameterProperties(roomCat);
                    if (cp.ParamDictionary.Count > 0)
                    {
                        spaceCategoryList.Add(cp);
                    }
                }

                BuiltInCategory bltSpace = BuiltInCategory.OST_MEPSpaces;
                Category        spaceCat = categories.get_Item(bltSpace);
                if (null != spaceCat)
                {
                    CategoryProperties cp = new CategoryProperties(spaceCat);
                    cp.ParamDictionary = GetParameterProperties(spaceCat);
                    if (cp.ParamDictionary.Count > 0)
                    {
                        spaceCategoryList.Add(cp);
                    }
                }

                comboBoxSpace.ItemsSource       = spaceCategoryList;
                comboBoxSpace.DisplayMemberPath = "CategoryName";
                comboBoxSpace.SelectedIndex     = 0;

                List <CategoryProperties> elementCategoryList = new List <CategoryProperties>();
                List <ElementId>          filterCatIds        = ParameterFilterUtilities.GetAllFilterableCategories().ToList();
                foreach (ElementId id in filterCatIds)
                {
                    try
                    {
                        BuiltInCategory bltCat   = (BuiltInCategory)id.IntegerValue;
                        Category        category = categories.get_Item(bltCat);
                        if (null != category)
                        {
                            if (null != category.Parent)
                            {
                                continue;
                            }                                          //skip subcategories
                            if (bltCat == BuiltInCategory.OST_Rooms || bltCat == BuiltInCategory.OST_MEPSpaces)
                            {
                                continue;
                            }

                            if (category.HasMaterialQuantities)
                            {
                                if (category.CategoryType == CategoryType.Model)
                                {
                                    CategoryProperties cp = new CategoryProperties(category);
                                    cp.ParamDictionary = GetParameterProperties(category);
                                    if (cp.ParamDictionary.Count > 0)
                                    {
                                        elementCategoryList.Add(cp);
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        string message = ex.Message;
                    }
                }

                elementCategoryList             = elementCategoryList.OrderBy(o => o.CategoryName).ToList();
                comboBoxRevit.ItemsSource       = elementCategoryList;
                comboBoxRevit.DisplayMemberPath = "CategoryName";
                comboBoxRevit.SelectedIndex     = 0;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to display categories.\n" + ex.Message, "Display Categories", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }