title: How to add parameters to a revit family element from revit document in revit-api c#
body: <p>I'm working on a project where I need to load pipe fittings (bends) revit families on a revit document and update its shared parameters as type parameters. </p>
  
  <p>I was able to achieve this task since I needed to access the bend family as family instance.</p>
  
  <p>The second part of the requirement is to update the coupling family parameters of the bend as well.
  The problem is that I'm unable to access the coupling parameter from the revit document.</p>
  
  <p>If I try it manually, the coupling parameter is accessible only when I double click on the bend family, this opens the revit family file. I then can access both the coupling on either side of the bend.
  How can I achieve the above task of adding parameters to a revit family element from revit document programmatically.</p>
  
  <p>Please guide me.</p>
  
  <p>Thank You in advance.</p>
  
  <p>My Code:</p>
  
  <pre><code> foreach (var item in MainModel.listElement)//List&lt;Element&gt;
   {
      FamilyInstance elFamInst = item as FamilyInstance;
      if (elFamInst.Symbol.FamilyName == "MainFamilyName")//Bend Family
      {
         ElementId id = item.GetTypeId();
         ElementType et = doc.GetElement(id) as ElementType;
  
         Family fam = elFamInst.Symbol.Family;
  
         if (elFamInst.SuperComponent == null)
         {
            var subElements = elFamInst.GetSubComponentIds();
            if (subElements.Count != 0)
            {
               foreach (var aSubElemId in subElements)
               {
                  var aSubElem = doc.GetElement(aSubElemId);
                  if (aSubElem is FamilyInstance)
                  {
                     FamilyInstance subEl = aSubElem as FamilyInstance;
                     Family fm = subEl.Symbol.Family;
                     if(subEl.Symbol.FamilyName == "subFamilyName")//coupling family
                     {
                         Document docfamily = doc.EditFamily(fam);
                         if (null != docfamily &amp;&amp; docfamily.IsFamilyDocument == true)
                         {
                            FamilyManager familyManager = docfamily.FamilyManager;
                            using (Transaction trans = new Transaction(docfamily, "param"))
                            {
                                trans.Start();
                                FamilyParameter fp = familyManager.AddParameter("Namess",BuiltInParameterGroup.PG_IDENTITY_DATA,ParameterType.Text, false);
                                familyManager.Set(fp, "JP");
                                trans.Commit();
                            }
                          }
  
                      }
  
                    }
                 }
               }
            }
         }
      }
  </code></pre>
  
  <p>I am unable to achieve the result, also I want the parameter "JP" to be set only on the coupling family i.e. the parameter with the name "subFamilyName".</p>