title: How to increase the speed of finding elements?
body: <p>This code performs extremely long time and in the end, doesn't accomplish its goal - combine element's parameters inside of a schedule. It clearly happens due to a large number of elements of the category &quot;Pipe Fitting&quot; in the project. How to increase the speed? Is it through selecting elements using some scheduled class?</p>
  <p>Win Forms GUI is used.</p>
  <pre><code>Document revitDoc { get; set; }
  
              public Form1(Document doc)
              {
                  InitializeComponent();
  
                  this.revitDoc = doc;
                  //Create a list of the parameters you want your user to choose from 
                  List&lt;string&gt; stringParameters = new List&lt;string&gt;
              {
                  &quot;GP_Description&quot;,
                  &quot;GP_Model&quot;,
                  &quot;GP_Angle&quot;             
              };
                  //Add list to comboboxes on form 
                  foreach (string parameterName in stringParameters)
                  {
                      comboBox1.Items.Insert(0, parameterName);
                      comboBox2.Items.Insert(0, parameterName);
                      comboBox3.Items.Insert(0, parameterName);
                     
                  }
  
              }
  
          private void button1_Click(object sender, EventArgs e)
          {
  
              FilteredElementCollector collector = new FilteredElementCollector(revitDoc);
              ElementCategoryFilter filter = new ElementCategoryFilter(BuiltInCategory.OST_PipeFitting);
                
              IList&lt;Element&gt; ducts = collector.WherePasses(filter).WhereElementIsNotElementType().ToElements();
  
              foreach (Element duct in ducts)
              {
       
                  Parameter parameter1 = duct.LookupParameter(comboBox1.Text);
                  Parameter parameter2 = duct.LookupParameter(comboBox2.Text);
                  Parameter parameter3 = duct.LookupParameter(comboBox3.Text);
                 
                  List&lt;string&gt; parameterValues = new List&lt;string&gt;();
  
  
                  if (parameter1 != null)
                  {
                      string parameterValue1 = parameter1.AsString();
          
                      if (parameterValue1 != &quot;&quot;) parameterValues.Add(parameterValue1);
                                 
                  }
      
                  if (parameter2 != null)
                  {
                      string parameterValue2 = parameter2.AsString();
            
                      if (parameterValue2 != &quot;&quot;) parameterValues.Add(parameterValue2);
                                         
                  }
          
                  if (parameter3 != null)
                  {
                      string parameterValue3 = parameter3.AsString();
                    
                      if (parameterValue3 != &quot;&quot;) parameterValues.Add(parameterValue3);
  
                  }
                     
                  if (parameterValues.Count &gt; 0) 
                  {
                    
                      string newValue = String.Join(&quot; ,&quot;, parameterValues);
  
                      using (Transaction t = new Transaction(revitDoc, &quot;Set Parameter name&quot;))
                      {
                          t.Start();
                          duct.LookupParameter(&quot;Outcome&quot;).Set(newValue);
                          t.Commit();
                      }
  </code></pre>