Nested ForEach with Boolean Return

Very new to Dynamo and my only programming experience is with C#. Any help would be appreciated.

I have two lists of strings; one is a list of the names of the StructuralFraming members from the model and the other is a list of the members I want to keep. Programming through the API this would simply be a nested foreach loop to test each value in the names list against all the values in the test list. Like this (I’ll call the lists Names and Test):

foreach (string x in Names)

{

foreach (string y in Test)

{

if (x==y)

return true;

}

}

For the output I need a list matching the Names list in length that contains boolean values. I cannot figure out how to do this with the code blocks and there don’t appear to be any nodes that will do it either.

Hi Adrian,

Try using “formula” node.

Hi Adrian, all you need to do is use the equals node or == and turn on cartesian product lacing on that node. Dynamo will then compare every item in one list against all items in the other.

You can definitely do this with code blocks as well, for loop is: (for i in list)

MatchPython

Seems like all you need is List.ContainsItem

20151216-1

 

1 Like

Wow! Thanks you all very much!