BIMSource.SPWriter.ParameterAssigner.BindSharedParameters C# (CSharp) Method

BindSharedParameters() public method

public BindSharedParameters ( ) : bool
return bool
        public bool BindSharedParameters()
        {
            if (File.Exists(m_sharedFilePath) &&
              null == m_sharedFile)
              {
            MessageBox.Show("SharedParameter.txt has an invalid format.");
            return false;
              }

              foreach (DefinitionGroup group in m_sharedFile.Groups)
              {
            foreach (ExternalDefinition def in group.Definitions)
            {
              // check whether the parameter already exists in the document
              FamilyParameter param = m_manager.get_Parameter(def.Name);
              if (null != param)
              {
            continue;
              }

              BuiltInParameterGroup bpg = BuiltInParameterGroup.INVALID;
              try
              {
            if (def.OwnerGroup.Name == "Dimensions")
            {
              bpg = BuiltInParameterGroup.PG_GEOMETRY;
            }
            else if (def.OwnerGroup.Name == "Graphics")
            {
                bpg = BuiltInParameterGroup.PG_GRAPHICS;
            }
            else if (def.OwnerGroup.Name == "Model Properties")
            {
                bpg = BuiltInParameterGroup.PG_ADSK_MODEL_PROPERTIES;
            }
            else if (def.OwnerGroup.Name == "Overall Legend")
            {
                bpg = BuiltInParameterGroup.PG_OVERALL_LEGEND;
            }
            else if (def.OwnerGroup.Name == "Electrical")
            {
                bpg = BuiltInParameterGroup.PG_ELECTRICAL;
            }
            else if (def.OwnerGroup.Name == "Mechanical")
            {
                bpg = BuiltInParameterGroup.PG_MECHANICAL;
            }
            else if (def.OwnerGroup.Name == "Electrical - Lighting")
            {
                bpg = BuiltInParameterGroup.PG_ELECTRICAL_LIGHTING;
            }
            else if (def.OwnerGroup.Name == "Identity Data")
            {
                bpg = BuiltInParameterGroup.PG_IDENTITY_DATA;
            }
            else if (def.OwnerGroup.Name == "Data")
            {
                bpg = BuiltInParameterGroup.PG_DATA;
            }
            else if (def.OwnerGroup.Name == "Electrical - Loads")
            {
              bpg = BuiltInParameterGroup.PG_ELECTRICAL_LOADS;
            }
            else if (def.OwnerGroup.Name == "Mechanical - Air Flow")
            {
              bpg = BuiltInParameterGroup.PG_MECHANICAL_AIRFLOW;
            }
            else if (def.OwnerGroup.Name == "Energy Analysis")
            {
              bpg = BuiltInParameterGroup.PG_ENERGY_ANALYSIS;
            }
            else if (def.OwnerGroup.Name == "Photometrics")
            {
                bpg = BuiltInParameterGroup.PG_LIGHT_PHOTOMETRICS;
            }
            else if (def.OwnerGroup.Name == "Mechanical - Loads")
            {
              bpg = BuiltInParameterGroup.PG_MECHANICAL_LOADS;
            }
            else if (def.OwnerGroup.Name == "Structural")
            {
              bpg = BuiltInParameterGroup.PG_STRUCTURAL;
            }
            else if (def.OwnerGroup.Name == "Plumbing")
            {
              bpg = BuiltInParameterGroup.PG_PLUMBING;
            }
            else if (def.OwnerGroup.Name == "Green Building Properties")
            {
              bpg = BuiltInParameterGroup.PG_GREEN_BUILDING;
            }
            else if (def.OwnerGroup.Name == "Materials and Finishes")
            {
              bpg = BuiltInParameterGroup.PG_MATERIALS;
            }
            else if (def.OwnerGroup.Name == "Other")
            {
              bpg = BuiltInParameterGroup.INVALID;
            }
            else if (def.OwnerGroup.Name == "Construction")
            {
                bpg = BuiltInParameterGroup.PG_CONSTRUCTION;
            }
            else if (def.OwnerGroup.Name == "Phasing")
            {
                bpg = BuiltInParameterGroup.PG_PHASING;
            }
            else
            {
              bpg = BuiltInParameterGroup.INVALID;
            }

            m_manager.AddParameter(def, bpg, false);

              }
              catch (System.Exception e)
              {
            MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            return false;
              }
            }
              }
              return true;
        }

Same methods

ParameterAssigner::BindSharedParameters ( string filePath, bool isInstance ) : bool

Usage Example

Example #1
0
        private bool AddParameters()
        {
            Document doc = m_app.ActiveUIDocument.Document;

            Autodesk.Revit.ApplicationServices.Application app = m_app.Application;
            ParameterAssigner pa = new ParameterAssigner(app, doc);

            MainWindow mw = new MainWindow();

            mw.ShowDialog();
            if (mw.DialogResult == true)
            {
                string filepath   = ParameterSettings.filePath;
                bool   isinstance = ParameterSettings.isInstance;

                Transaction t = new Transaction(doc, "Bind Shared Parameters");
                t.Start();
                bool succeeded = pa.BindSharedParameters(filepath, isinstance);
                if (succeeded)
                {
                    t.Commit();
                    return(true);
                }
                else
                {
                    t.RollBack();
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
All Usage Examples Of BIMSource.SPWriter.ParameterAssigner::BindSharedParameters