Get Built In and Shared for FamilySymbol

Get Built In and Shared for FamilySymbol

atis.sed
Advocate Advocate
203 Views
1 Reply
Message 1 of 2

Get Built In and Shared for FamilySymbol

atis.sed
Advocate
Advocate

Hi, 

what would be optimal way of retrieving Built In and Shared Parameters (if the Shared Parameter is not added as Project Parameter)  for all FamilySymbols (Family) in Doors Category?
For now my approach is like this:

public static FilteredElementCollector FilterBuiltInElements(Document doc, Category selectedCategory)
{
	// Filter out elements that are only for built in categories
	// and where elements are Element Types NOT instances
	BuiltInCategory builtInCategory = selectedCategory.BuiltInCategory; // Get built in category for selected category
	var elementFilter = new ElementCategoryFilter(builtInCategory);
	FilteredElementCollector elementCollection = new FilteredElementCollector(doc)
		.WherePasses(elementFilter)
		.WhereElementIsElementType();
	return elementCollection;
}

public static List<Parameter> GetBuiltInAndSharedParametersForFamilyType(IEnumerable<Element> elements)
{
	List<Parameter> elementParameters = elements
		.First() // Get only the first element because all FamilySymbol elements are of the same category and therefore have the same FamilySymbol parameters
		.GetOrderedParameters()
		.Where(param => IsBuiltInParameter(param) || param.IsShared)
		.ToList();
	return elementParameters;
}

 

It works well if the Shared Parameter are added as Project Parameter to Door Category.

I could loop through all FamilySymbol elements and combine parameters, but maybe there is more elegant way of getting Shared Parameters for FamilySymbol ? 

0 Likes
Accepted solutions (1)
204 Views
1 Reply
Reply (1)
Message 2 of 2

jeremy_tammik
Alumni
Alumni
Accepted solution

Looks OK to me, maybe a bit overly complicated. There is an official SDK sample that does stuff like this, and much more besides. Maybe you ought to take a look:

  

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open