Imagine you want to use Dynamo to place an adaptive component, let’s take an adaptive component with 2 insertion points. In that case you need to provide the AdaptiveComponent.ByPoints node a list with points organized by 2 in sublists:
List.Chop is a node that can be used to do so.
But what if the list has an impair number of points. In that case you will have at the end a sublist with only one point:
Of course the AdaptiveComponent.ByPoints node will return an error because it needs 2 points. This means that we need to check if the last list has just one point, if yes we need to remove this sublist.
There are several ways to do so. Here a first(but not the best) solution:
What we do here is to count all the items in each sublist with the List.Count node. Then, with the == node, we check if there is a sublist with just one item. With the IndexOf node we will get the indices of all these lists. And finally we remove them with the List.RemoveAtIndex node.
But as always in Dynamo you can have several solutions for the same problem. Here is a second solution using 3 nodes instead of 6:
With the ContainsKey node we will check if all sublists have an item with index 1. Each sublist with 2 points will return true, but the sublists with just one point will return false.
With the FilterByBoolMask we can then filter out only the sublists whith the true value (=with 2 points in it).