//Room/Area/Floor >> Mass
        private bool TransferToMass(Dictionary <Element, FamilyInstance> mapDictionary)
        {
            try
            {
                foreach (Element mainElement in mapDictionary.Keys)
                {
                    FamilyInstance massInstance = mapDictionary[mainElement];

                    foreach (string paramName in defDictionary.Keys)
                    {
                        ExternalDefinition extDefinition = defDictionary[paramName] as ExternalDefinition;
#if RELEASE2013 || RELEASE2014
                        Parameter mainParameter = mainElement.get_Parameter(paramName);
                        Parameter massParameter = massInstance.get_Parameter("Mass_" + paramName);
#elif RELEASE2015 || RELEASE2016
                        Parameter mainParameter = mainElement.LookupParameter(paramName);
                        Parameter massParameter = massInstance.LookupParameter("Mass_" + paramName);
#endif
                        if (null != mainParameter && null != massParameter && !massParameter.IsReadOnly)
                        {
                            using (Transaction trans = new Transaction(m_doc))
                            {
                                trans.Start("Set Parameter");
                                switch (mainParameter.StorageType)
                                {
                                case StorageType.Double:
                                    massParameter.Set(mainParameter.AsDouble());
                                    break;

                                case StorageType.Integer:
                                    massParameter.Set(mainParameter.AsInteger());
                                    break;

                                case StorageType.String:
                                    massParameter.Set(mainParameter.AsString());
                                    break;
                                }
                                trans.Commit();
                            }
                        }
                        else if (null != mainParameter && null == massParameter) //create Mass Parameter
                        {
                            Family   family    = massInstance.Symbol.Family;
                            Document familyDoc = m_doc.EditFamily(family);

                            if (null != familyDoc && familyDoc.IsFamilyDocument)
                            {
                                using (Transaction fTrans = new Transaction(familyDoc))
                                {
                                    fTrans.Start("Add Parameter");
                                    FamilyParameter fParam = familyDoc.FamilyManager.AddParameter(extDefinition, BuiltInParameterGroup.INVALID, true);
                                    switch (fParam.StorageType)
                                    {
                                    case StorageType.Double:
                                        familyDoc.FamilyManager.Set(fParam, mainParameter.AsDouble());
                                        break;

                                    case StorageType.Integer:
                                        familyDoc.FamilyManager.Set(fParam, mainParameter.AsInteger());
                                        break;

                                    case StorageType.String:
                                        familyDoc.FamilyManager.Set(fParam, mainParameter.AsString());
                                        break;
                                    }

                                    familyDoc.LoadFamily(m_doc, new FamilyOption());
                                    fTrans.Commit();
                                }
                                familyDoc.Close(true);
                            }
                        }
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to transfer data from " + massCategory.ToString() + " to Mass.\n" + ex.Message, "Form_DataTrnasfer:TransferToMass", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }
        }
        private void bttnToRoom_Click(object sender, EventArgs e)
        {
            massCategory = GetCategory();

            iniDataManager = new INIDataManager(m_app, massCategory);
            defDictionary  = new Dictionary <string, Definition>();
            defDictionary  = iniDataManager.DefDictionary;

            string parameters = "";

            foreach (string param in defDictionary.Keys)
            {
                parameters += "[" + param + "]  ";
            }

            bool result = false;

            switch (massCategory)
            {
            case MassCategory.Rooms:
                result = TransferToRoom(roomDictionary);
                break;

            case MassCategory.Areas:
                result = TransferToRoom(areaDictionary);
                break;

            case MassCategory.Floors:
                result = TransferToRoom(floorDictionary);
                break;
            }

            if (result)
            {
                DialogResult dr = MessageBox.Show("Parameters values have been successfully transferred from Mass to" + massCategory.ToString() + ".\n" + parameters, "Updated Parameters", MessageBoxButtons.OK, MessageBoxIcon.Information);
                if (dr == DialogResult.OK)
                {
                    this.DialogResult = DialogResult.OK;
                }
            }
        }
        public Form_Parameters(UIApplication uiapp, MassCategory category)
        {
            try
            {
                m_app        = uiapp;
                m_doc        = m_app.ActiveUIDocument.Document;
                massCategory = category;
                InitializeComponent();
                string currentAssembly = System.Reflection.Assembly.GetAssembly(this.GetType()).Location;
                string definitionPath  = Path.GetDirectoryName(currentAssembly) + "/Resources/Mass Shared Parameters.txt";
                using (Transaction trans = new Transaction(m_doc))
                {
                    trans.Start("Open Parameter Definition");
                    m_app.Application.SharedParametersFilename = definitionPath;
                    definitionFile = m_app.Application.OpenSharedParameterFile();
                    trans.Commit();
                }

                if (null == definitionFile)
                {
                    MessageBox.Show("Cannot find a definition file for shared Parameters.\n", "Form_Parameters:" + category.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to initialize the form of parameters.\n" + ex.Message, "Form_Parameters:" + category.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }