I am just getting started in Dynamo and I was attempting to create a simple script to delete all unused Line Styles in a Revit project file. I started the script and successfully extracted a list of all the Line Styles contained in the project as well as the ones being used in the project. I am trying to filter out the line styles being used through Filter by Boolean Mask, but am stuck on the step right before that. When I try to search the original list with the list of only the line styles being used, I do not get a complete list of boolean values. I can’t figure out why but it seems to only check the first x amount of lines in the list (if there are 2 line styles being used in the project, it only searches the first 2 lines). It doesn’t search using the text in the lines being input, instead it just returns the first 2 items from the original list since i an searching for list items. I have tried searching for it as list items as well as strings using the String.Contains node but they both seem to give me the same result. Which steps am I missing and what am I doing wrong?
You’re actually getting different results (that look the same) because the nodes are doing different things and handle lists differently.
List.Contains checks to see if a single Item appears in an entire List (it’s already expecting a list input). Both of your items appear in the list so they both return True. If you want to see where in the list the items appear, flip the inputs.
String.Contains searches a single item for a single string. The reason it only returns 2 values is because it’s set to Shortest Lacing, meaning that it’s comparing the lists per each index - once one list is complete the process stops. It works fine with one search value because Dynamo assumes that every list item should be checked. If you want to search for multiple values you need to use a different lacing. I’ve shown examples using the == node. Shortest Lacing checks x against y and x against y. Longest Lacing does the same thing but continues to use the last index of the shortest list to compare all elements in the longest list. Cross-Product Lacing (which is what you want to use) checks each item in the first list with each item in the second list.
Hopefully that clears things up a bit, but I strongly encourage you to go through the Dynamo Primer to learn all the basics of list management. It will make things much easier.
Thank You, this explanation really helped! I started changing the lacing and seeing how it affected the lists like you explained and showed. I had started looking through different sections of the Dynamo Primer but will definitely continue going through it to get a better understanding of how Dynamo works. Thanks Again!