Complex list compare with multiple structure

Hello ,

A brain burning question for you. Tips are very welcomed.

How to compare list with multiple structure?
I don’t understand the second condition “WALL_02”, it seems like this part didn’t work at all.

ListTest.dyn (28.1 KB)

Hi @Congzheng ,

Please search around on the forum, this question has been asked a lot already

Thanks, I’ll search again in the forum.

Doesn’t it work if you just change the y input to `@@L2`? Or could you include the exact desired output?

Is this what you are aiming for?

1 Like

@Congzheng In case if you are looking for a Python solution:

``````OUT = []
for toChecks,checkFors in zip(IN[0],IN[1]):
temp = []
for toCheck in toChecks:
if toCheck in checkFors:
temp.append(True)
else:
temp.append(False)
OUT.append(temp)
``````
2 Likes

no, if I do that, the result lost the data structure.

Exactly !
I couldn’t do it in Python because of the mutiple data structure.
Besides, I am always trying to learn Python but I couldn’t find a good way. The logic is too difficult for me to understand. Do you have some advices ?

Yes, it can be one of the solution but needs to use boolean AND / OR to get the result.

In terms of advice, I would say; avoid creating complex list-structures and focus on getting easy-to-manage single lists of data. If you ever have to append your definition, it will make things much easier for you, or for your colleagues. I would focus on getting doors into one list, walls into another, windows into a third…and then dealing with those lists individually…especially when you want to start sorting them. The community here is (almost) always happy to help.

In which list? I typically use the “IF” node as AND/OR Gates.

If true, then true = 1 and false = 0

then I add those together in order to filter on AND / OR Conditions.

For “OR” conditions, only one condition must be met, and therefore the sum only needs to be greater than 0.

For “AND” conditions, I can set two, three, four, five different conditions and the result must fulfill all of them; thus the sum will be either two, three, four or five respectively.

Here is an example:

1 Like

Hi Matthew,

Thank you very much for your kind advice. It’s a smart and clear strategy.

I would be happy to discuss the complicity of this subject.

The story begins with analysing the .ifc files, to ensure if the BIM models have the specified data.
Here is the level of the data :

1. a list of different .ifc files (architecture, structure, MEP, …)
2. tens of categories
3. tens of parameters
4. different types of data (they should be filled in according to the fixed formats)

In order to analyse the data from ifc files, my current soultion, is to export ifc to excel. (It could be great if data can be obtained from ifc without open it)
Since I can’t make operation with 4 levels of complicity, I will avoid analyse all the ifc files in one shot, so I analyse one ifc each time.
Still, I will make a pulldown list for categories, so each time I analyse one category.
Now the data will be more clean, I only need to deal with different data types and compare with their objective formats.
Since each time I will receive different ifc file, the parameters of this category and its objective formats will be very dynamic. So I divide all the objective formats into several groups, each group has only one similar format type, i.e. they all start with a fixed code( but still varies from projects).
That’s why I arrive here - analyse a bunch of two-level data. one ifc / excel > one category > one type of objective format.

But as you said, avoid creating complex list-structures. I always asking myself if it’s because the mission is complicated or I made it complicated. Despite I tried to make workflow clear.

@Congzheng Start with a basic Python course on Youtube and learn the basics.
Then you can dive into these resources:

Keep an eye out for what people are doing on this forum. It’s a great place to learn as well!

4 Likes

When I need to script something complex (like what you are trying to accomplish) I typically break that down into smaller individual scripts. These scripts are then numbered to run them in a predefined order.

Trying to create one script to do 20 things is much more difficult to create, troubleshoot and adjust than breaking that down into multiple smaller pieces.

It sounds like you are attempting to do some data-validation with Excel.

I’m not sure what the final output needs to look like, but I might offer a few other solutions: DataValidation of the IFC-Files with Solibri (expensive) or DataValidation of the IFC-Files with Revizto 5. (You can create view filters, and exchange BCF-Files.)

If you are still wanting to use dynamo:
I would recommend starting with one model type (for example architecture) and one category (for example, doors) and creating a template from that. Don’t try processing complex lists with multiple lines of data; build one “line” of data-processing and then copy-and-swap the differences out.

The major drawback to this is obviously, making corrections or adjustments to the scripts. It’s a real issue, so try and get one script working as elegantly as possible. Here is an example of a relatively complex script for processing technical openings:

I would recommend grouping elements in dynamo, color coding, and keeping things neat in order to make understanding and adjusting the script easier to understand. If I open a complex graph which is disorganized, it will take me 30 minutes just to figure out what it is doing, and what the intent is. I use groups like they are blocks of codes with comments: Read Excel File, Create Origin Point, Set Parameter, Change Workset, etc.

I also recommend using the CTRL+L button as you move along to keep things tidy if you aren’t already in the habit of doing so.

Happy to help and contribute more…but I need to run!

Please, keep us updated!

1 Like

Hallo, ich bin zurück. Just finished a topo related project which was squeezed in last week.

Thanks for your advices. I am agree with start with one model type. The manager advised me the same - start with architecture because structure or MEP is more complicated.
In spite of using SimpleBIM (relatively cheaper than Solibri and Revizto) to help with data-validation, there still have tens of diverse processes and it’s super time consuming. That’s why I am trying to liberate my colleagues from this boring repetitive work. Analyse the data in Dynamo first and then visualize them in PowerBI.

Solibri do has the possibilites to create analysis template, but it’s still not convient. I may start with Dynamo, and wait for one day that we are able to read ifc data in dynamo without open it.

Considering the analyse strategy, we had the same idea. I just added a drop down list with Data-shapes plugin to switch between different categories. So one script can deal with one model type.

Maybe I can use List.Map node to make a loop process, but I am not sure if dynamo can read and write data to Excel multiple time without close the script.

Thanks to @AmolShah the whole process almost works correctly. The last issue(I hope so) is to deal with Empty List. I don’t know how to tell python, if i in IN[0] is Empty List, don’t pass anything because the next node will produce a 0 which increases the list length.

In summary, after this script finish, I will rethink the analysis process and make another version that each script do simply process individually. 0_o

Beside, I don’t know why, for the same process, Grasshopper is much more faster than Dynamo.

Ohh, nice. Thanks. I will definitely take a look !

My personal experience. I had the programming class in the university, I didn’t pass it because I had difficulty to understand the program logic. Then I’ve followed a two weeks full time Python class, I’ve also completed Dynamo for Revit: Python Scripting by Jeremy Graham.

In general, I understand the example script, but when I do my own stuff, it’s not working.
Quite disappointing me but I don’t mind. I am wondering if it’s because I didn’t find the right entrance.

@Congzheng You won’t need a new Python node for that.
Try doing something like this:
` [[],y][x?0:1];`

1 Like

Oh, that is so nice. Very easy to understand.

I also got another idea when i wake up this morning. Use If node

@Congzheng Yes, you can use the if node here.
What I suggested is also using if condition but through the DesignScript.

I was thinking of this case when lists lengths won’t be equal and that throws off the If node.

But I guess you wouldn’t face that issue since you won’t be using the List.Empty node.

So go ahead and use the If node to keep it simple.

1 Like

Yes you are right. If node only works with simple list. Finally I abandoned If node for this case.
I’m quite curious, why If node didn’t work in this case? if “test” receive “false”, pass the data from “false”, non?

@Congzheng When the list lengths of true List and false List are unequal, the If node likes to match the list lengths to the minimum number.

In your case the length of List.Empty is 0 and of List [2,0,1] is 3.
But since minimum length is 0, it reduces the List [2,0,1] to List.Empty and outputs that.

2 Likes