Hello everyone,
I have a list of SharedParameterElements, which contains all Shared Parameters in my document.
I'm trying to find out which categories the different parameters are added to, but when I use the code below, I only get null. Even if I use the Revit LookUp-tool, I get null in categories.
Can anyone tell me what I'm missing?
sortedSharedParameters = new List<Element>();
FilteredElementCollector coll = new FilteredElementCollector(document);
coll
.WhereElementIsNotElementType()
.OfClass(typeof(SharedParameterElement))
.ToList();
sortedSharedParameters = coll.OrderBy(p => p.Name).ToList();
foreach (Element e in sortedSharedParameters)
{
SharedParameterElement sp = (SharedParameterElement)e;
string category = sp.Category.Name;
}
Thanks in advance,
Niclas
Solved! Go to Solution.
Solved by TripleM-Dev.net. Go to Solution.
Hi, Look into ParameterBindings; ParameterBindings Property
Get it's iterator and each element is a ElementBinding (instanceBinding for instance state)
The ElementBinding has a Categories property with the bound categories to the Project parameter
- Michel
Thanks for the reply @TripleM-Dev.net - and sorry for the late respond. Been off programming for a while..
But you led me in the right direction with ParameterBindings.
I ended up with the code below, and from there I could loop through each parameter, to get the categories.
List<Parameter> pamLst = new List<Parameter>();
BindingMap bindingMap = document.ParameterBindings;
DefinitionBindingMapIterator it = bindingMap.ForwardIterator();
while (it.MoveNext())
{
Definition definition = it.Key;
InternalDefinition internalDefinition = (InternalDefinition)definition;
ElementBinding elementBinding = (ElementBinding)it.Current;
foreach (Parameter e in pamElement)
{
if (e.Id == internalDefinition.Id)
{
pamLst.Add(e);
}
}
}
Thanks again!
Can't find what you're looking for? Ask the community or share your knowledge.