Code issue with creating automatic sheets

I am having issue with the automatic creation of Revit sheets. The node I am using is Sheet.ByNameNumberTitleBlockAndView. My sheets are being numbered and named fine for the most part, but some views will wind up on the wrong sheets or in some cases a sheet will be made and the view wont be placed on it. Any ideas why?

I want to take my plumbing views and separate them out. My sanitary views are to be numbered starting with 200, water starting with 300, and so on. I use String.Contains and List.FilterByBoolMask to achieve this. I have been mostly successful with this. In the case where I want my plumbing roof plans views to be separated out, since there is also a roof plan under mechanical and electrical, I first filter by “plumbing” and then do another round with “roof”…is there a more efficient way? I there a way to just say to look for the views that contain both “plumbing” AND “roof” in one code block?

Is there a way to make my code more efficient in general? I have tried using a code block to write a for loop or a while loop but I am missing something or a few things on how to write the actual code properly. I’ve taken the node groups and just copied and pasted a bunch.
Below shows the craziness. Right now it is just looking at floor plans, but I want to also add drafting views to this. My first three nodes are ViewType which I selected floor plan in the drop down, which connects to Views.GetByType, which connects to Element.Name+ , which then connects to all the groups.

Here is the first step to simplify your graph:


Multiple String Contains.dyn (9.9 KB)

Notice the cross lacing for the String.Contains node and the @L2 for the List.AllTrue node. If both of the inputs (plumbing and roof in this case) are found in a single string, the List.AllTrue node will return True.

In general, if you are copying and pasting the exact same group of nodes, you should most likely be instead using a list of inputs along with list levels to maintain the data structure you need. Rather than using Input A for Group A, Input B for Group B, etc., you should use a single group of nodes and provide a list of [Input A, Input B, Input C].

Thanks. Would you happen to know why some views wind up on the wrong sheet?

Most likely related to a lacing or levels issue. You can create a graph with some dummy data to test your logic and ensure you get the expected result before working with your actual project. Something like this:

OK I will give that a try