Family Parameters

Family Parameters

psh.t
Contributor Contributor
842 Views
4 Replies
Message 1 of 5

Family Parameters

psh.t
Contributor
Contributor

Hello, Forum-board users! Would you so kind to give me a hint as I'm a bit confused. So, how can I get and change parameters of an active document if this document is a Family itself? If the Family is open in the project I usually do this way:

 

FilteredElementCollector FamilyS = new FilteredElementCollector(doc)
                                                      .OfClass(typeof(FamilySymbol));
foreach (FamilySymbol FS in FamilyS)
{
   foreach (Parameter P in FS.Parameters)
   {
      if (P.Definition.Name == "My Parameter")
      {
            //here I'm dealing with the parameter
      }
  }
}

But if the open document (doc) is the Family, then doc.Parameters doesn't exist. I tried to do next:

FilteredElementCollector ParamElem = new FilteredElementCollector(familyDoc)
                                                         .OfClass(typeof(ParameterElement));
foreach (ParameterElement PE in ParamElem)
{
      if (PE.Name == "My Parameter")
      {
      //My parameter was got as a result but in PE there's no method for to change it in PE
      }
      foreach (Parameter P in PE.Parameters)
      {
          if (P.Definition.Name == "My Parameter")
          {
           //My parameter wasn't got
         }
    }
}


Then I tried to do this:

FamilyManager FM = familyDoc.FamilyManager;
foreach (FamilyParameter FamilyP in FM.Parameters)
{
    if (FamilyP.Definition.Name =="My Parameter")
      {
       //My parameter was got as a result but in PE there's no method for to change it in FamilyP 
      }
     foreach (Parameter P in FamilyP.AssociatedParameters)
     {
          if (P.Definition.Name == "My Parameter")
          {
              //My parameter wasn't got
          }
     }
}

Fnd that's all.

Павел Тер-Микаэлян
email: psh.t@inbox.ru
0 Likes
Accepted solutions (1)
843 Views
4 Replies
Replies (4)
Message 2 of 5

psh.t
Contributor
Contributor
Accepted solution

I found the answer:

http://thebuildingcoder.typepad.com/blog/2009/11/family-parameter-value.html

Павел Тер-Микаэлян
email: psh.t@inbox.ru
0 Likes
Message 3 of 5

jeremytammik
Autodesk
Autodesk

Thank you for posting the solution you found.

 

I marked it as an answer to close this thread.

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 4 of 5

Anonymous
Not applicable

Dear jeremy Recently
I'm study this article "Family Parameter Value" (including the example code),but compare with the 2017 sample on GitHub have some question as below:

1 Why the "CmdFamilyParamValues.cs" is different in each version?(link 1-1~2)

2 As the Revit API Doc I can't find "get_Elements" method but have "GetElementClass Method". Could you explain why?(link2)

 

link: 1-1 https://thebuildingcoder.typepad.com/blog/2009/11/family-parameter-value.html

1-2 https://github.com/jeremytammik/the_building_coder_samples/tree/master/BuildingCoder/BuildingCoder

2 https://thebuildingcoder.typepad.com/blog/2009/09/document-elements.html

0 Likes
Message 5 of 5

jeremytammik
Autodesk
Autodesk

Thank you for your questions.

 

Those are some pretty old posts you are referring to.

  

1. Things change. In fact, the only constant is change.

  

2. get_Elements was in fact auto-generated from the `Elements` property. Since it takes an argument, unlike a 'normal' property.

 

The `Elements` property was replaced by filtered element collectors almost ten years ago.

 

The most common way (almost the only way) to retrieve elements from the Revit database is via filtered element collectors:

 

https://thebuildingcoder.typepad.com/blog/about-the-author.html#5.9

 

Cheers,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder