Compare 2 Sub-lists in Grasshopper


SOLAR COMPLIANCE_Testing 2.gh (13.4 KB)

Hi, I would like to compare 2 SUBLISTS. The first list will have a single branch with a single path of {0;0}, and the second list will have 2 branches of 2 paths which are {0;0}, {0;1},… and path {1;0}, {1;1},… I would like to insert 0 if the numbers of the second list wont match the first list. For instance, the first list has a series of numbers with 9, 9.5, 10, 10.5, 11, 11.5, 12, 12.5, 13, 13.5, 14, 14.5, 15. A sub-branch of the second list maybe just 11, 11.5, 12. and the result I want is 0, 0, 0, 0, 11, 11.5, 12, 0, 0, 0, 0, 0, 0. The Evaluate component works if the second list is a single branch when compared to the first list which is also a single branch, but the second list I work on now has 2 big branches (and maybe More), each of them has 36 smaller branches of different numbers of items in it. please refer to the image attached for reference. Thank you!

If I understood correctly, this can be done with the Replace Item component:

SOLAR COMPLIANCE_mrtn.gh (14.6 KB)

2 Likes

Hi Martin, this is what I need, you save my time, thank you very much!!!,

1 Like

Hi Martin, and also wonder in this hierarchy list structure, if I could extract the steps of non-continuous numbers on the list? for example one of the branch gets 9, 9.5, 0, 0, 0, 11.5, 12, 12.5, 0, 0, 0, 14.5, 0. So the number I would like to have in this list will be 1 (9 to 9.5) and 3 (11.5 to 12.5), 14.5, and will be ignore. Thank you!
GH

On the screenshot above…

Index 2 is the first occurence of a set of ‘0’

Index 8 is the second occurence of a set of ‘0’

Index 12 is the third occurence of a set of ‘0’

Hi Martin, Sorry, I still don’t know how I could extract that numbers as in the same file you have done.
Could you elaborate it more, thank you!

Why 1 and 2 in the panel on the right?

Because 9 - 9.5 is 1 step, 11.5, 12, 12.5 is 2 steps.

Actually, It come from this result of having the list of 2 (9, 9.5), 3 (11.5, 12, 12.5) , 1 (14.5). then I will just need to minus 1 for each of them to have 1 (2-1) and 2 (3-1) to get 1 & 2.

Thank you!

So that is the list length of continuous numbers minus 1, correct?

Yes, thank you!

I found this one which is similar to my case to count the list length for true and false at the end, but unfortunately it does not apply to my hierarchy branches.

PS: This doesn’t work so I deleted the file.

Hi Martin, thank you very much, but when I compare 2 lists, the numbers are not quite right. please see the image here. thank you!

Ok, I see the problem. An d I think I found a solution. I added a few numbers in branch 7 to test a scenario with three sub-lists instead of just two.

The partial results of a comparison of the relative differences can be used to filter paths for each sub-list.

SOLAR COMPLIANCE_mrtn.gh (28.0 KB)

1 Like

Hi Martin,

Thank you very much, this is what I need. Cheers!!!

1 Like