Help understanding someone else's graph with python

Hi everyone,

I am trying to deal with a quite complicated Dynamo graph we inherited from our previous BIM-Manager and need help to understand what it does here…

So first I am supposed to choose a Revit-Element with the node SelectRevitElements and connect it to the IN[0] of a PythonNode that contains:

I = IN[0]

f = open(“N:\1000 Allgemein\Keys.txt”)
L = f.readlines()
L1 = int(L[11])

if (L1 == 10243):
OUT = IN[0]
OUT = “”


The txt-file contains:

This is a connection file, DO NOT CHANGE IT!


Can anyone tell me what Python is doing there? It gives me back the Element and its ID…

Hi @bialmeida,

The Python script does the following:

  • Reads the text file
  • Checks the 12th line of the text file (index position 11)
  • If the integer value of the value at that line is equal to 10243 the node returns the element that was input as IN[0]
  • If the integer value is not equal to 10243 then the node returns a blank string
  • Closes the text file

I wasn’t sure which line the text file starts on, and the whole thing seems a bit convoluted. Do you know how the text file is generated?

Hope this helps,


I dont really understand it because the graph goes on and on and uses a lot of Code blocks, i am not familiar with them… the current txt-file has 10243 on line 12 (index 11) and a text on line 1 (Index 0) as in “created by xxx” so it will return the name of the person who created the graph.

I also noticed there is no OUT in the python script, so the Node-output is the same as the node Input…
and then i would have a second Question: this Code block with t1 to t5 is only asking the Inputs for their Family type? I guess i could just replace it for a node Element.ElementType, right?


The BIM Manager created a logic for himself, I think. He wanted to use spesific elements in a script but somewhere not. So he created a logic with numbers. Maybe with project numbers… so Python checks if number is OK for that condition it can call Family from first node. If number is different maybe on another project then do not take the fist family…

1 Like

I also noticed there is no OUT in the python script, so the Node-output is the same as the node Input…

The Python does have an OUT, it is within the conditional if / else statement, so the OUT isn’t necessarily the same as IN[0], it’s the logic I outlined above where if line 12 is the 10243 then OUT will be the same as IN[0], otherwise it will be an empty string.

As @Deniz_Maral suggests, it’s probably some kind of test to prevent a graph running to its conclusion if certain conditions aren’t met. There are easier/clearer ways of achieving this if that was the aim.

this Code block with t1 to t5 is only asking the Inputs for their Family type? I guess i could just replace it for a node Element.ElementType, right?

Yes, that would achieve the same result


that’s right, my mistake. it means also that the graph doesn’t work without the txt-file… maybe this txt will be generated later on the graph, i’ll eventually find out hopefully… thanks for that!

now there’s some Problem with a custom node and thats why the graph is not functioning right now. As I said, I am not familiar with code blocks, so maybe you guys can help me understanding that as well?

The Input “Element” would be a second Revit Element coming from a second node Select Revit Element. The Input “Family Type” is the Family coming out of the python node we were Talking About, and the Input ElementsToFilter was connected to a node “All Elements in Active View”. What was he trying to output here (Looks like 5 different Outputs?)? For some reason, once I run the graph this node outputs null…

Thanks a lot!!

Hard to say from the screengrab what is the problem is, but it would be helpful to show the yellow warning message at the top of the code block and, if you are able, to post the dyf of the custom node because there’s also more Python nodes to the right.

If the Name of the single element input doesn’t correspond to an element in elementsToFilter then I think the node would fail beyond t13 because there would be no elements to do the remaining actions on

1 Like

Thank you very much!
dyf.dyf (26.6 KB)

What version of Dynamo are you using?

i am currently using 2.0.1

It looks like the DesignScript within the custom node was written in Dynamo 1.x so some of the syntax has been deprecated. That will be causing some of the problems but it’s tricky to diagnose without knowing what the aim of the node is. I can see it has something to do with placing detail items, is that your understanding?

1 Like

Hi @bialmeida

Try this dyf(ForBialmeida).dyf (26.8 KB)

1 Like

that is right, it was written in 1.x.

The graph was created because we would get dwg-Files from the MEP-Engineers and would use them as a reference to place revit Familys, lighting fixtures for example. As we work with very big Projects and thousands of Lights in every Floor, the idea was to Import the dwg and explode it partially, so that we could select the autocad-blocks and replace them with revit Familys (Detail components). Does that make sense?

That works, thank you very much! The only problem is that i unfortunatelly still don’t understand exactly what this node is doing… I am learning, so I am very curious and experimenting as much as I can. I learned python (Basics) and I am getting familiar with the Dynamo nodes. Would you also recommend me to learn how to work with this Code blocks? Thank you very much!

You can take a look here:

1 Like