Applying values to Revit Parameter Using a List

I need assistance with an issue I’m facing involving lists. My goal is to search for a space name using the “contains” function and based on the result, assign a value to a specific parameter. I’ve been able to get this working for a single space type at a time, but I want to optimize the process by using a list and a single graph for the entire operation.

Please refer to the images below for an example of what I’m trying to achieve.

Graph that works:

Graph that doesn’t work:

I would appreciate any assistance with this request. Thank you in advanced.

Lacing might be an option, but I think that lacing through nodes can easily become confusing in such situtation. Using a python node and some simple loops is more intuitive and easier to understand.
me_space_param_assginment.dyn (6.7 KB)

pairs = [("Class", "Speakers Only"), ("Elec", "Horn Strobe"), ("Elev", "Speaker Strobe"), ("Corridor", "Horn Only"), ("Break", "Speaker Only"), ("Data", "Speaker Strobe")]

test = []
#Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)

for e in elems:
    for key, value in pairs:
        if key in e.get_Name():
            e.LookupParameter("FA Area Hatch").Set(value)
            break

TransactionManager.Instance.TransactionTaskDone()

And you can use dictionary if you are dealing with enormous amount of spaces.

Thank you very much for your response. I am just not that familiar with Python to know where to put the node or what to do with it. I am trying to learn Dynamo and fumbling my way around. All I am trying to do is compile my graph, so I do not have so many copies of the same thing but with some names changed. The graph attached works exactly how I want but I feel like there is a better way to achieve this in a concise manor.

Set Parameter Value By Space Name.dyn (76.2 KB)

I really appreciate your assistance with this request.

I know what you mean and if you take a closer look at your graph, the only difference among the routines are name keys of space which is used in the “Contain” logic and corresponding parameter values to be assigned to spaces. Naturally, you could work towards a “logic unit” that takes a name key and yields a parameter value. Alternatively, you could put name keys and parameter values side by side in pairs then use the first item to search for a space then immediately assign the second item to the space’s parameter. It’s a good idea to look into list lacing, List.Map and get a feel of how certain nodes broadcast its values towards a list with different length. I am not sure if this will be more concise visually, but it might be easier for you to understand and maintain.

As @BimAmbit mentioned.
Use Lacing (> Cross Product) on the String.Contain node.

You probably need to use List.AnyTrue in between the
List.AnyTrue and List.FilerByBoolMask (with correct level. I think should be at @2).

In my opinion there is really no need for Python in this case.

Thanks everyone!! Through your suggestions I was able to get the script to do what I wanted. I appreciate all of your help. Below is an image of the new consolidated script.