Hello guys I’m struggling with the Element Type Property sets and deconstructing them using the Speckle Deconstruct nodes, and I’ve tried C# scripting to resolve the issue and I can’t wrap my head around how this works.
I have a list of windows that I want to separate between glass and frame. I found that the material info is found under element type property sets. However, upon deconstructing these, I got a index range error, since some dictionaries from Element Type Property Sets have 6 entries, some 7 and some 8.
I thought I’d write a C# component to group all entries with similar lengths to a separate group, but then the output I get is a Generic List that can’t be deconstructed using Speckle’s node. Here’s my code:
private void RunScript(List<object> inputList, ref object groups)
{
// A dictionary to hold the groups.
// The key is the entry count (int).
var groupsByCount = new Dictionary<int, List<object>>();
// Loop through every item provided to the component.
foreach (var item in inputList)
{
// Check if the item is a dictionary
if (item is System.Collections.IDictionary dict)
{
int count = dict.Count;
// create a new list for the dictionary with said entries.
if (!groupsByCount.ContainsKey(count))
{
groupsByCount[count] = new List<object>();
}
// Add the object to its group.
groupsByCount[count].Add(item);
}
}.
var outputGroups = new List<List<object>>(groupsByCount.Values);
groups = outputGroups;
}
Am I missing something here?