Get the possible values for a family instance parameter

Get the possible values for a family instance parameter

o_s_
Contributor Contributor
183 Views
4 Replies
Message 1 of 5

Get the possible values for a family instance parameter

o_s_
Contributor
Contributor

I have a parameter of family instance called DoorEnd.
The values of this parameter are a list of family types (OST_DuctTerminal).

I know the following way to get all possible values:

Element element =  document.GetElement(doorParameter.AsElementId());
IEnumerable<FamilySymbol> possibleValues = new FilteredElementCollector(document)
   .WhereElementIsElementType()
   .OfCategory(element.Category.BuiltInCategory)
   .OfClass(typeof(FamilySymbol))
   .Cast<FamilySymbol>();

But the value of this parameter is represented as NestedFamilyTypeReference:

o_s__0-1755691999999.png

As far as I understand, it is impossible to collect the list because it is nested.

If you have any ideas on how to collect possible values, please share them.
Thank you.

0 Likes
184 Views
4 Replies
Replies (4)
Message 2 of 5

o_s_
Contributor
Contributor

Hello @jeremy_tammik

Do you have any ideas on how to do this?

0 Likes
Message 3 of 5

sragan
Collaborator
Collaborator

I'm not sure I quite understand your example.  Just a guess, but are you sure you don't want the FamilySymbol.Family?

 

Looking at this example code to get the family name and family type of a duplex receptacle:

Get a specific family name and type, and place it:

FilteredElementCollector familyCollector = new FilteredElementCollector(doc);

familyCollector.OfClass(typeof(FamilySymbol));

 

                    FamilySymbol familySymbolToFind = null;

 

                    foreach (FamilySymbol familySymbol in familyCollector)

                    {

                        //To search by FamilySymbol name

if (familySymbol.Name == "receptacle" && familySymbol.Family.Name == "duplex")

                            familySymbolToFind = familySymbol;

                       
                    }// end foreach

uidoc.PromptForFamilyInstancePlacement(familySymbolToFind);

 

0 Likes
Message 4 of 5

FAIR59
Advisor
Advisor

the family can tell you the valid Ids for a familytype-parameter : GetFamilyTypeParameterValues 

			FamilyInstance inst;			
			Parameter doorend;
			
			Family fam = inst.Symbol.Family;
			ISet<ElementId> candidates = fam.GetFamilyTypeParameterValues(doorend.Id);
			IEnumerable<ElementId> symbols = new FilteredElementCollector(doc,candidates)
				.WhereElementIsElementType()
				.ToElementIds();
			// remove symbols from candidates
 			candidates.ExceptWith(symbols);
			// candidates now only contains the Ids of NestedFamilyTypeReferences
0 Likes
Message 5 of 5

TripleM-Dev.net
Advisor
Advisor

Looks like that familytype used in the FamilyType parameter isn't a shared one, but one in the family itself and you can't get to that in a project, you would need to open the family.

 

See: https://revapidocs.com/2020.htm?id=ff71e3b0-4300-7d04-1356-a045b9a90407.htm 

=> " nested FamilyType Element in the original Family Document where the family was defined."

 

So I suspect when a shared family is used for the FamilyType parameter a actual elementtype will be returned and the filter for the Category will work.

 

However if i'm correct the category can be obtained from the Parameter itself, but how depends on the Revit Version.

For Revit 2022 and up something like:

 Category.IsBuiltInCategory(Definition.GetDataType) => it it matches a builtin category it's a FamilyType and you can get the category from it.

 

See https://revapidocs.com/2022.htm?id=efbd8409-b82b-11d8-4b20-65ffc27b750e.htm 

0 Likes