Dictionary.SetValueAtKeys as list

Hi,

I have created a list of dictionaries with list as one of the values for key “geometry”. Now I want to replace the value with the new list but it keeps putting only the first item of the list in the value. Dictionary at index 1 before had 2 items, now only one.

But a workaround works where I extract keys and values as separate lists, then replace item from values list with the new one and recreate the dictionary

how can I get the SetValueAtKeys to work? I have a feeling that it’s simple and can’t be bothered creating new dictionary every time.

Hope I’m making sense,
Luka

First of all, careful if you’re not trying to update the geometry list of all those dictionaries at once.

You’re close with SetValueAtKeys. Keep in mind the list structure that the node is expecting versus what you’re supplying. The node states both the keys and values inputs are expecting lists. So a list of keys corresponds with a list of values, i.e. it’s a one-to-one comparison. If you supply a singular key with a list of values the node will assume that the lists are mismatched and you’re missing some keys. In order to get around this you have to supply a singular key and a singular list of values. (I know that’s kind of confusing.)

All of that is to say you probably need one more list level in your new values. For a singular dictionary you could also set the list level to be one above the size of the list. This would force the extra level and give the same result. But that won’t work when you already have the additional list levels due to a list of dictionaries.

Easier to see with a single dictionary.

Still works with multiple.