Hi, Is it possible to have string starts with node search multiple values? I see it’s been done before, but its not working for me the way I’d like. Any help is appreciated!
You just need to set your list levels to search each string for both values. Change the string
input on String.StartsWith
to @L1
and the List.AllFalse
input to @L2
.
I’m a beginner so I may be misunderstanding, but it sounds like your saying I need a list for every string im searching for? In the link I posted I have what seems to be identical to Thomas’ graph, but maybe the older version works different.
Maybe someone can respond with what this should look graphically. My goal is to find all sheets that either start with A1, A2, A3 and so on, and not sheets that are A7, A8, A9, eg.
Change the list levels like I mentioned and see if that does what you’re expecting. You have all the right pieces, you just aren’t telling your nodes how to handle the input structures correctly.
@L1
will make it so that each string you’re checking gets treated as the only input for each permutation. This will make it so that each search value is checked against the string individually, returning a boolean for each condition. You can then use @L2
on AllFalse
to check the sublist pertaining to each initial string (sheet number).
What @Nick_Boyts is directing for you to do as circled in red. You may also need to set the lacing to longest as circled in blue.
Ahh nice! That part of nodes is foreign to me so thank you for the image. I’m getting closer, but I’m missing the A2s from the list. I’d like to get a list that has both A1s and A2s and any additions I add.
Try to understand what list levels do: specify the level of a list structure to treat as an individual input. Some inputs expect a single item and some expect a list. List levels can help you specify the correct structure (via a specified level) from within a more complex structure.
You want each sheet number to check for any of the search terms you’ve included. Using @L1
would tell String.StartsWith
to treat each item (at the L1
dimension) to iterate through the node using the rest of the inputs one item at a time.
Using @L2
for List.AllFalse
would tell the node to check each list found at the L2
dimension (rather than the full list of lists).
You can usually tell you’ve chosen the right list levels if your outputs match the original structure (or a scaled version if you’ve added list dimensions).
As @Nick_Boyts states, levels and lacing is a major part of Dynamo in basically every aspect. It would benefit you greatly by learning what they do and how those selections interpret lists. Not sure why you are using the “List.AllFalse” node though. If you feed the bool out from the “String.StartsWith” node straight into the “List.FilterByBooleanMask” you should get two lists coming from the “in” output. First list should be all of the sheets starting with A1 and second list should be all of the sheets starting with A2. The “out” output from the boolmask node would also be two lists each consisting of all the other sheets that didn’t match the criteria or false returns.
some background on the topic of List and Level
That would be two sublists - one without A1 and one without A2. At a minimum you would need to use a List.SetIntersection on the results from the out list, and that data can be MUCH more complex than the booleans which proceed the List.FilterByBoolMask. Likely won’t matter for a smaller dataset and only two tests, but if you wanted to test say 100 proceeding strings against 3000 sheets and suddenly you have 300,000 outputs from the filter by boolean mask and the String.StartsWith node… well generally the sooner you can reduce to 3000 values the better.
I would assume that if he eliminates the “List.AllFalse”, then he would just use what’s coming out of the “in” output which should only be all of the A1 and A2 sheets. He shouldn’t/wouldn’t need to mess with the “out” output at all. Unless I am missing something.
Filter by bool mask node would have 300000 items in memory instead of 3000 in my example. Again not much of a concern with 2 booleans but with 100… yeah that adds up.
Some design script could clear that up though.
Oh I didn’t think about that. Thanks!