Create new list by extracting desired items from existing list

Hello there, i’m kind of a newbie to Dynamo, i think this is a simple one, but i’m just not used to the terminology to lay out what i need.

All i would like, is to create a new list from the existing one, that lists only 100mm, and not the other pipe sizes.

So either its a new list by removing the other numbers, or a new list by only taking 100’s, i’ve tried several nodes and ways, but cant say it correctly.

Cheers!

Try using a filter by bool mask. May not be the most efficient way, but its the first that came to mind. See below:

2 Likes

Might need to build the mask via String.Contains instead of == as the values may not be as consistent.

3 Likes

Well that worked, thank you!

thanks, i didn’t think of using the = to be more precise. makes sense now i think about it.

Jacob, using List.Contains might prove to be problematic depending on the user’s unique input, correct?

Say your list contains the numbers 4, 44, and 404, and you only want the index of “4”, using List.Contains will give you “true” for all 3 numbers. Same as if you have a list containing 100 and 1000. Asking for the index containing 100 will give you the index for both 100 and 1000.

Search for "4 " and thr index of the first space will work out in that case. :slight_smile:

You are correct in that generally speaking it’s best to convert to numbers and use an equality test though, but I wanted to acknowledge the discrepancy in the data type as 100 != "100" after all.

2 Likes

Awesome! I did not know that little trick with the space. I’ll definitely be utilizing that in the future!

1 Like