Dear Jeremy,
Basically I created a list of total elements in the project using one of your codes (thank you!):
public List<Element> GetElementsProject(Document document)
{
Dictionary<string, Category> categories = new Dictionary<string, Category>();
FilteredElementCollector collector = new FilteredElementCollector(document);//elementCollector will filter all elements in the project (i.e. doc)
collector.WhereElementIsNotElementType().WhereElementIsViewIndependent().ToElements();
List<Element> elements = new List<Element>();
foreach (Element element in collector)
{
//make sure that, if the element is null, then I will not consider it (otherwise it would give errors later on)
ElementType elementtype = document.GetElement(element.GetTypeId()) as ElementType;
if (elementtype is null)
continue;
if (null != element.Category
&& 0 < element.Parameters.Size
&& (element.Category.HasMaterialQuantities))
{
if (!categories.ContainsKey(
element.Category.Name))
{
categories.Add(
element.Category.Name,
element.Category);
}
elements.Add(element);
}
}
return elements;
}I think I just added a line where I make sure that, if an element type is null, I will ignore it (otherwise it would crash my code).
Then I query each element in that list (using the foreach block). Before the foreach block I create an instance int index =0; which, in the end of the foreach loop, I will add a value to it. Basically I could replace the 'foreach' with a 'for' block (still learning programming!). The index allow me to screen each variable inside the lists (e.g. ListA[index];), it isn't related with the parameter value.
What I have is List_A, which contain the name of all elements, and then List_B, which contains a Parameter_Value also for all elements. So they have the same size.
E.g. index = 0; I will obtain the first instance in List_A (e.g. Wall1) and corresponding parameter in List_B (e.g. PV = 2), then index=1; I will obtain the second instance in List_A (e.g. Door1) and corresponding parameter in List_B (e.g. PV=5), and so on.
So, before the colouring, I've checked the max and min value in List_B. Then, the 'foreach' block will compare the Parameter_Value in each element with the max and min values.
I hope I've clarified the code a bit more now. If not, just let me know!
Cheers
Ruben