Replace Empty Lists with Profiles


I am writing a script to place sleepers for 300 rail alignments. unfortunately some of the alignments do not have a profile and my list management gets messy. how can I replace empty lists with a dummy profile?

Hi @Reto,

You could use the List.Clean node to remove the empty lists. Or List.IsEmpty could be used to figure out which indices the empty lists are at, and then you could do something after that to replace the items at those indices.

Aside from that though, I’m curious how the rest of the graph will work if you’re using a dummy profile? Won’t the sleepers be at the wrong elevations?

Lastly, it looks like you may want to use Block.GetBlockByName instead of Block.ByName, which is used for creating new block definitions.

Thanks Zachri, if I clean the list of profiles how can I clean the list of CantInfoatStation the same way so they still match?

Some ideas below. This way, you don’t have to filter all the lists that come from the alignments (profiles, cant info, etc.). You can just start by getting only the alignments that have profiles, then go from there.

2 Likes