I’m trying to replace the “empty list” values in my original list with the first non-null value of that same list.
I’ve tried all the suggested solutions on the forum but keep on running into problems.
When I create a bool mask that checks whether a given index is empty, the resulting list is 11 indexes longer than the original list, which results in a “list mismatch” error when using it in the List.MergeByBoolMask.
Empty Lists are not included in the item count, so I’m guessing you have 190 items/lists and 11 Empty Lists.
Does anyone have any suggestions on how to replace the empty lists with a constant value?
What I’m trying to do with this script is the following:
1 - grab some Revit geometry (easy)
2 - explode it to its faces (easy)
3 - grab the material from each face (some python needed)
4 - then combine all the faces with the same material in one object (easy…as long as the list from 2 and 3 are the same length!)
5 - write a separate .sat export for each unique material. (easy)
In the end, I would bring in each .sat separately in Formit. Because each .sat is grouped on import, I would have an easier time reassigning the materials.
However, I got stuck at step 3.
When I convert the Dynamosurfaces to Revitfaces (using the Revitface.FromDynamoSurface node), I sometimes get an “empty list” as result.
The problem is, I can’t just drop the emptylists as I want to combine the list from step 2 (geometry) with the list from step 3 (materials) and they need to be the same length for that to work properly.
Anyone any idea how to replace nested “empty lists” with something else?
List.ReplaceEmptyList from Clockwork will replace empty lists with a constant value.
However, if step 2 returns an empty list, step 3 should also return a null/empty list as it won’t have any material, so your lists should match in the end - unless your python code is cleaning up or skipping empty lists. You can probably get around this just by changing how your python code handles empty lists.
Thanks for your reply.
The empty lists only appear after converting the dynamo faces to Revit surfaces. Apparently it has some faces don’t have a Revit equivalent. However, I don’t want to drop these faces as it might break some solids (which I really want to keep intact for later use in Formit).
I tried the List.ReplaceEmptyList but I couldn’t get it to work on a nested list. Am I doing something wrong here?
Thanks from me and my colleagues for your time Nico and Nick! We appreciate it.
Ok, I had to add another level to the lists in order to support different categories. And now my replaceemptylists node is not working again!
Anyone any ideas?
set level on @L3
and if you want 4 levels then connect a list.create node after List.ReplaceEmptyList