# List.NormalizeDepth

Hi’ there!
I’ve been banging my head against this challenge for the last few days and come to the conclusion - I need your help.

The problem is that, when a single familyType per Family is fed into the Parameter.GetValue node from Orchid (@erfajo) the parameter values are returned on another level compared to if it’s fed with two familyTypes per Family.

So I’m trying to uniform the depth of the list so that the Item at Index 3 gets the same Level Depth as Items at Index 2, 4, etc. (See the last image)

I’ve basically tried all I know (NormalizeDepth, Count+Flatten+Chop, GetItemAtIndex+NormalizeDepth+Flatten+ReplaceItemAtIndex), but no luck.
There must be a very simpel and obvious way of doing this - I just don’t know it

Hope there’s someone who can help.

It’s a bit hard to see your screengrab but does List.NormalizeDepth with a rank of 3 do what you need?

@Thomas_Corrie No, it won’t work. I’m also taking the valueByType output.
In your example I need `826` and `Single Leaf Door` to be in the same list at Index 0.

• `[2] List`
• `[0] List`
• `[0] 826`
• `[1] Single Leaf Door`
• `[3] List`
• `[0] List`
• `[0] ...`
• `[1] ...`

I understand. There’s probably a better way, but this bit of Python looks through the lists and normalizes the structure. It’s specific to this level of nesting but could be adapted easily for different situations

``````fams = IN[0]

out = []

for fam in fams:
out.append([])
for count, ft in enumerate(fam):
if type(ft) == list:
out[-1].append(ft)
else:
if count == 0:
out[-1].append(fam)

OUT = out``````

Hi there,

1 Like

Hi @p.canini
The problem with you solution is that if you provide a parameter which does’t exit in some families the list is not always the same length.
See example.

Awesome @Thomas_Corrie. It worked
I’d be interested in seeing if anyone comes up with a OOTB solution. I’ve marked your reply as the solution.

1 Like

a little Python can do the trick
Rank = IN[0]
Values = IN[1]
List=
for i in range (len(Rank)):
if Rank[i]!=1:
List.append(Values[i])
else:
List.append([Values[i]])
OUT=List

yup @Martin_Romby ,

that is the even better trick. and I think it’s even the tidier one because you always get parallel lists for each parameter with nulls when you get no match. it’s a nicer format to be put in an excel table.

when trying really hard to deal with list structure - why not try using dictionaries… of dictionaries, or maybe lists of dictionaries in this case.

Would this OOTB approach work?
parameterValue.dyn (12.5 KB) (ver 2.2)

Yes, was thinking about that. Maybe it’s time for that.

I’ll have a look at if it’ll work with the rest of the graph. Many of the other value’s I’m extracting is per Type and not per Parameter.

I’m not sure, since I’m working with familyDocuments opened in the background. This give another approach than if they are loaded into a project.

transposing is exactly there to reorder according to the Type sorting