Need help with Python

Need help with Python
I am ignorant in Python, and I would have to program a node
Can you help me
Values are numbers.

X1 (list), Y1 (list), E (list), M (an integer)
Values (output)
X2 (list), Y2 (list), L (list)
If X1 = E
X2 = X1
Y2 = Y1 + M
L = Y2
X2 = X1 + M
Y2 = Y1
L = X2
*************** French
Besoins d’aide en Python
Je suis ignorant en Python, et j’aurais pesoins de programmer un nœud
Pouvez-vous m’aider
Les valeurs sont des nombres.
Valeurs (entrée)
X1 (list) , Y1 (list) , E (list) , M (un nombre entier)
Valeurs (sortie)
X2 (list) , Y2 (list) , L (list)
Formules :
If X1 = E
X2= X1
Y2= Y1 + M
L= Y2
X2= X1 +M

Get started then come back when you get stuck. There are many examples on this forum you can follow, plus stack overflow, the Dynamo primer, etc etc. Autodidacts reign supreme.

Ps. You’ve practically written the script in python, you just need to format it


Thank you for this answer which will not make much progress for me …

Hello, this page could help to get started with Python nodes:
And here is the way to present a code into forum posts:

Courage! :slight_smile:


It’s not the courage that’s missing, but the time …

Thanks for the link, but I have already been there.

The big problem for me is the translation with google! (Although I found links in france for python).

Learning Python shouldn’t be a problem but this forum is not the place for it. But you will find good examples such as this one:
You can then paste your code here to get further advice from experts…

If time is the problem and Dynamo is un-chartered territory for you, then its clearly the wrong tool for the job.

Unfortunately learning is nothing but time consuming I’m afraid and as much of an investment as you make it.

Like @Yna_Db said, this is not a Python forum. However, we’re happy to help you out when you are stuck, but first you have to give it a go. The reply from @Thomas_Mahon earlier was actually encouraging you to do just this, your psuedocode is pretty close so converting to Python isn’t that hard, so give it a go and then come back after you have and we can help point out where it’s going wrong.



One test but does not function line 40

1 Like

Hi @Alain_Hamel ,
you’re missing an indent on lines 40 and 43 (because you’re inside a loop).

1 Like

thank you for your reply.
Is the amendment correct?
I have another error:
Avertissement:IronPythonEvaluator.EvaluateIronPythonScript l’opération a échoué.
Traceback (most recent call last):
File “”, line 40, in
IndexError: index out of range: 1

@Alain_Hamel can you please paste your code here ?

Like that?

code (975 Bytes)

Like this :relaxed:

1 Like

You had an issue line 21 :

appending IN[2] to a list adds the whole list as a nested list. The length of that list will be 1. I just changed that…

import clr
from Autodesk.DesignScript.Geometry import *
#Les entrées effectuées dans ce noeud sont stockées sous forme de liste dans les variables IN.
dataEnteringNode = IN

#The inputs to this node will be stored as a list in the IN variable.
A = IN[0]
B = IN[1]
E = IN[2]
M = IN[3]

listX1 = []
listY1 = []

listX2 = []
listY2 = []

listE = []

listE  = E

#convert lists
if hasattr(A, '__iter__'):
	for i in range(0,len(A)):

if hasattr(B, '__iter__'):
	for i in range(0,len(B)):

# matched lists
lists = []

for i in range(0,len(listX1)):
	if listX1[i] == listE[i]:


#Assign your output to the OUT variable
OUT = lists
1 Like

Thank you for your help.
This is just a tabulation problem?

I’ll finish the code

My pleasure :slight_smile:

you had the tabulation problem on line 41 and 43 at first.
The other issue was the way you defined listE :
listE.append(E) is different from listE = E.

Yes, I just wanted to mimic the list code X1.append (A)

thank you,
The completed code:


I understand. If you had mimicked it all the way it would have also worked:

   if hasattr(E, '__iter__'):
    	for i in range(0,len(E)):

This part checks whether E is a list :

   if hasattr(E, '__iter__'):

if it is then it appends each element of the list to listE one by one.
if E is a single element and not a list, it will be appended to listE.

Anyway congrats on your first python code! :slight_smile: !!