What does this Python Code do?

I have a “Get Rid of Unused Room Separation Lines” dynamo graph that seems like it should work fine without a dangling Python node that is attached to it. But when I try removing the python node it doesn’t work. So now i am trying to understand what the python node is even doing.

Here is the Graph as a whole:

And here is what is loaded in the Python node:

That python node is pretty confusing. Most of the imports aren’t being used and the way the for loop is set up is confusing as well. The SetElementIds method’s description says “Selects the elements”, so it is essentially just selects the elements you feed into the node. Given a list of elements, e.g. [A, B, C, D], each element and all previous elements will be selected.

select = []
elements = [A, B, C, D]
result = []
for element in elements:
    append element to selection
    make python list of elements into .NET List
    select elements in currrent .NET List
    append "Success" to result

If you follow “select” through the loop, after the first iteration it only contains [A], after the second it contains [A, B], etc. Rather than selecting all elements at the same time, they are being selected sequentially.

Long story short, it just selects the elements, but I have no idea why this would affect the rest of the graph.


Thanks for that explanation. I really appreciate it. And yeah - I am super flummoxed now, as a script that “selects” elements and then, for each element selected, posts a message of “Success” doesn’t seem to actually DO anything… relative to the rest of the Dynamo Graph

I am going to try it again - see if i can get the graph to work without the python script.

…so bizarre.

and now it is working without the python script.
that is so weird