- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Honestly, sometimes I feel so daft; is it me or the API? I want to return a list of all Family Instances by name. All samples, including the Revit API docs, pass a name, but this is in fact the Type name. As the Type name is not unique (i.e. "Type 1") and can be used by different Families, this seems to be incorrect. The following is the example from the Revit API Docs:
// Use ElementClassFilter to find family instances whose name is 60" x 30" Student ElementClassFilter filter = new ElementClassFilter(typeof(FamilyInstance)); // Apply the filter to the elements in the active document FilteredElementCollector collector = new FilteredElementCollector(document); collector.WherePasses(filter); // Use Linq query to find family instances whose name is 60" x 30" Student var query = from element in collector where element.Name == "60\" x 30\" Student" select element; // Cast found elements to family instances, // this cast to FamilyInstance is safe because ElementClassFilter for FamilyInstance was used List<FamilyInstance> familyInstances = query.Cast<FamilyInstance>().ToList<FamilyInstance>();
To correctly return a list of FamilyInstances, surely the collector needs to be passed the following, in order:
1. Category
2. Family Name
3. Family Type Name
I have been unable to find an example, and I have been unable to assemble a filter statement to correctly limit the returned instances. Am I missing/overlooking something? Can anyone point me in the right direction? Thanks, Dale
______________
Yes, I'm Satoshi.
Solved! Go to Solution.