Get the possible values for a family instance parameter

Get the possible values for a family instance parameter

o_s_
Contributor Contributor
151 Views
3 Replies
Message 1 of 4

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
152 Views
3 Replies
Replies (3)
Message 2 of 4

o_s_
Contributor
Contributor

Hello @jeremy_tammik

Do you have any ideas on how to do this?

0 Likes
Message 3 of 4

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 4

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