Set Area Name into an objects

Hello everyone,
I’m trying to create a small script but I’m stuck.
The idea is that the script associates all objects with the area in which they are located.

I associated each object (for example generic models) with a project parameter called “Location”.
If all objects are inside the area, there are no problems, the script works. But if some objects are not inside an area the problems begin.

If “Element.AreaLocation” is null, the script crashes. For this reason I tried “List.clean” , but doing so it no longer maintains the order of the objects and the parameters are written randomly.
Then I tried with “ReplaceByCondition”, writing “out” for the objects in which “Element.AreaLocation” is null, but in this case I can no longer read the area names and therefore it writes null to all objects not inside an area. I’m missing a node that allows me to join the two lists.

Thanks everyone for the support.

Cleaning the list is going to leave you with mismatched values. Instead, you just want your nulls to remain blank (or give them the “out” value). You can use a conditional to replace nulls with your new value ("" or "out") and then set the value of every object.

Try to reconnect the nodes as follows…


@p.wehbi thanks for your reply. I had already tried to set it as you suggested, the problem is that “element.area location” collides with the first null value and the script crashes.

this is exactly my problem, but i don’t know how to sort or combine the lists and then tell the “get paramater” to read the area name.

Consider using List.FilterByBoolMask node to filter out the undesired items

2 Likes

Look into conditionals. No need to sort or combine. If the instance has an area then you can get the name, if it doesn’t (null) you can return a different value.

It looks like you’re in an older version of Dynamo where nodes will still fail for a list if the first value is null. To get around that, you probably need to do everything in a single-line code block.

Another option would be to filter like @p.wehbi suggested and set the values for your two conditions separately.


Thanks to all, i’ve resolve in this way with Boolean Mask