Replacing empty values for multiple type parameters

Hi Everyone

I’m trying to create a script that replaces all empty (blank) values with a “-”. I want the script to review multiple parameters. In this example, the script looks at the type parameters (Fire Rating and Type Mark) for all door types. (Revit 2023)

Process:

  1. “String Length” node to identify all empty values less than 1,
  2. “Filter Boolean Mask” to separate the True and False Values,
  3. “Get Item at index” to separate the parameter lists (all empty values for Fire Rating parameter all empty values for Type Mark parameter),
  4. “If” node to replace True values with “-”,
  5. “Set Parameter by Name”.

8 attempts down, I’ve managed to get the script to add “-” to either all values or a select few.
when I run this script it remove the number 67 Type Mark in the schedule and replaces it with a - for some reason. It appears to count the parameters together as some sort of group even thought I separated them.

I’ve tried a variety of nodes “Replace empty /null”, and “String Replace”. However I can not get them to work.
I feel that it’s something to do with the levels structure.

I’d love to get it to work in a similar format that I’ve currently created since I’m trying to learning and feel a sense of pride in how far I’ve come with this. Could someone please help or point me in the right direction.

Door_Fire Rating Type Mark replace empty values.dyn (51.2 KB)

I think you’re almost there,

you need to also apply the fitlerbyboolmask on your list of elements

You are feeding the full list of elements instead of only the elements with an empty value

Just a note, you can use filterbyboolmask here, you’re comparing string values of booleans for no reason :slight_smile:

1 Like

Using list levels you can do this efficiently

1 Like

You have a lot of redundancies and a lot of extra steps that are actually making things harder for you. There’s no reason to take a boolean, convert it to a string, and then see if the string matches the boolean value only to get the same boolean back. You don’t need GetItemAtIndex to get specific items that you’ve already filtered out as blank. You’ve also lost your list structure by doing so.

Instead, you can just use a conditional to replace empty strings with the value you want to then push all those values right back to their respective parameters. No dealing with list structure. No dealing with filters. Everything stays 1-to-1.

2 Likes

Thank you @Garbage_Collector I can see the error of my ways now :smiley:

As always, thank you @Nick_Boyts. I don’t really understand that code block but it gives me something to research for sure.

It’s just an IF statement.
IF val == "", THEN "-", ELSE val
If the input value is empty, return a dash, otherwise return the input value.

1 Like

Hi Mike,
Maybe this is another topic I’m not sure, however If I change the category to Walls from Doors, it does not seem to work in the same way, it only replaces certain type values with a “”-, if I play around with the levels I get multiple results, I can not even get it to change any value under Type Mark for a Wall. what am I missing? Does a wall interact differently within Revit in relation to Dynamo?

There are subtle differences - walls are a system family that are baked into Revit, doors are a loaded family and are hosted by another family and their ‘type’ is known as a Family Symbol in the API. The parameters you are changing (‘Type Mark’ and ‘Fire Rating’) are built in parameters which are exactly the same for doors and walls. I ran the graph changing doors to walls, cutting the parameters to one and it was still working. The only thing I can think is that you may have missed the longest lacing on the equals node. It’s a bit hard without a screen shot of your graph

Can you show us?

@Mike.Buttery

I assumed it was something along those lines regarding walls and Dynamo / Revit interaction. The levels are slightly different in the attached graph (I also changed for the door example you provided earlier to make it work correctly as you showed). With category set to Walls I’ve tested the lacing, however due to my level of understanding it’s a trial and error process (change lacing, change levels, rinse and repeat…).

Schedule example (replacing all values with the -)

@Nick_Boyts

This code work great :grinning:

I found it satisfying and quite surprising what a small bit of text can achieve in a code block.

val == “” ? “-” : val;

I’ve added both of the Graphs in the dyn file.

Parameter test replace null value with …dyn (42.3 KB)

thank you!!

1 Like

The major benefit is the difference you’re seeing above: conditionally modifying the value means that your list structure stays exactly the same as your elements and you don’t have to deal with any filtering or list matching. Everything stays constant.

Related to that, I think using list levels on List.UniqueItems is adding unnecessary list levels. The list of element types should be a singular list of types. No need to force the structure on unique items for that. Your structure doesn’t match for each of the final inputs and that’s probably causing some problems.

That’s coming from my earlier response - this was required to get the list cycling aligned with the bool mask output so that setting parameters worked. I’m sure it is possible that you could do it, however at the time I was unable to get the levels working on the set parameters node without it