- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I was hoping someone more knowledgable than I could explain what I am seeing with the 2 code snippets below. The first grabs a colletion of Family type objects with a collector, while the second grabs a collection of FamilyInstance type objects.
Questions:
- Why is the list of parameters on the family objects completely different from the parameters on the FamilyInstances? I guess I assumed, a FamilyInstance was an instance of a family object, so it would contain the same parameters with all values specific to that instance, but that is clearly not the case. In my sample document, they share no parameters in common at all.
- The names of Family objects vs. FamilyInstance objects also are all different, so what is the relationship there?
Code Snippet 1
ElementClassFilter FamilyFilter = new ElementClassFilter(typeof(Family));
FilteredElementCollector FamilyCollector = new FilteredElementCollector(RvtDoc);
ICollection<Element> AllFamilies = FamilyCollector.WherePasses(FamilyFilter).ToElements();
foreach (Family Fmly in AllFamilies)
{
string FamilyName = Fmly.Name;
foreach (Parameter Param in Fmly.Parameters)
{
string ParamName = Param.Definition.Name;
}
}
Code Snippet 2
ElementClassFilter FamilyInstanceFilter = new ElementClassFilter(typeof(FamilyInstance));
FilteredElementCollector FamilyInstanceCollector = new FilteredElementCollector(RvtDoc);
ICollection<Element> AllFamilyInstances = FamilyInstanceCollector.WherePasses(FamilyInstanceFilter).ToElements();
foreach (FamilyInstance FmlyInst in AllFamilyInstances)
{
string FamilyInstanceName = FmlyInst.Name;
foreach (Parameter Param in FmlyInst.Parameters)
{
string ParamName = Param.Definition.Name;
}
}
The ultimate goal was to build a list of all parameters under each family in the Revit Document, but the differences I've encountered between Family objects and FamilyInstance objects has me fairly confused as to just how all of this works!
Thanks for any insight you can provide!
Solved! Go to Solution.