private void CollectFamilyNames()
        {
            try
            {
                selectedFamilies = new Dictionary <string, List <Family> >();

                List <int> familyIds = new List <int>();
                foreach (string category in typeDictionary.Keys)
                {
                    foreach (int typeId in typeDictionary[category].Keys)
                    {
                        TypeProperties tp     = typeDictionary[category][typeId];
                        Family         family = tp.FamilySymbolObject.Family;
                        if (familyIds.Contains(family.Id.IntegerValue))
                        {
                            continue;
                        }
                        familyIds.Add(family.Id.IntegerValue);

                        if (selectedFamilies.ContainsKey(category))
                        {
                            selectedFamilies[category].Add(family);
                        }
                        else
                        {
                            selectedFamilies.Add(category, new List <Family>());
                            selectedFamilies[category].Add(family);
                        }
                    }
                }
                foreach (string category in sysTypeDictionary.Keys)
                {
                    if (!selectedFamilies.ContainsKey(category))
                    {
                        selectedFamilies.Add(category, new List <Family>());
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to collect family names. \n" + ex.Message, "ElementDataCollector Error:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        public void CollectSelectedElementsData(List <ElementType> selTypes)
        {
            try
            {
                typeDictionary     = new Dictionary <string, Dictionary <int, TypeProperties> >();
                instanceDictionary = new Dictionary <string, Dictionary <int, InstanceProperties> >();
                sysTypeDictionary  = new Dictionary <string, Dictionary <int, ElementTypeProperties> >();
                sysInstDictionary  = new Dictionary <string, Dictionary <int, ElementProperties> >();
                viewTypeDictionary = new Dictionary <int, ViewTypeProperties>();
                viewInstDictionary = new Dictionary <int, ViewProperties>();

                if (selTypes.Count > 0)
                {
                    foreach (ElementType atype in selTypes)
                    {
                        progressBar.PerformStep();
                        FamilySymbol   famSymbol      = atype as FamilySymbol;
                        ViewFamilyType viewFamilyType = atype as ViewFamilyType;
                        if (null != famSymbol)
                        {
                            TypeProperties tp = new TypeProperties(famSymbol);
                            AddParameterInfo(tp.TypeParameters);

                            if (typeDictionary.ContainsKey(tp.CategoryName))
                            {
                                typeDictionary[tp.CategoryName].Add(tp.TypeID, tp);
                            }
                            else
                            {
                                typeDictionary.Add(tp.CategoryName, new Dictionary <int, TypeProperties>());
                                typeDictionary[tp.CategoryName].Add(tp.TypeID, tp);
                            }
                            StoreDataOfFamilySymbol(famSymbol);
                        }
                        else if (null != viewFamilyType)
                        {
                            ViewTypeProperties vtp = new ViewTypeProperties(viewFamilyType);
                            AddParameterInfo(vtp.ViewTypeParameters);

                            if (!viewTypeDictionary.ContainsKey(vtp.ViewTypeID))
                            {
                                viewTypeDictionary.Add(vtp.ViewTypeID, vtp);
                                StoreDataOfViewType(viewFamilyType);
                            }
                        }
                        else //system family
                        {
                            ElementTypeProperties etp = new ElementTypeProperties(atype);
                            AddParameterInfo(etp.ElementTypeParameters);

                            if (sysTypeDictionary.ContainsKey(etp.CategoryName))
                            {
                                sysTypeDictionary[etp.CategoryName].Add(etp.TypeID, etp);
                            }
                            else
                            {
                                sysTypeDictionary.Add(etp.CategoryName, new Dictionary <int, ElementTypeProperties>());
                                sysTypeDictionary[etp.CategoryName].Add(etp.TypeID, etp);
                            }
                            StoreDataOfElementType(atype);
                        }
                    }
                }

                CollectFamilyNames();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to collect selected Elements Data: \n" + ex.Message, "ElementDataCollector Error:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }