IronPythonEvaluator.EvaluateIronPythonScript failed .... 'list' and 'list'

Hi community,

i´m new in this forum and need your help in a little Dynamo <> Python issue i´ve got recently.

I created a python skript to compute the azimuth between two points in Dynamo. The Script works fine when the Input contains out of two Points. When i change the Input into two lists containing multiple points, i get an error. I attached the part of the Dynamo script as well as the python skript.

Is there someone who can help me with this issue? I would appriciate it a lot.

Thank you in advance and have a great start into the week
Max

Your script is expecting single values but your are inputting lists. Python doesn’t use replication like Dynamo does so I suppose that’s what’s confusing you. You need to iterate over your list inputs, i.e. modfy your Python code so llist inputs can be handled.

2 Likes

Hello,
here is a solution (not necessarily the most effective with regard to my current skills)

# Charger les bibliothèques DesignScript et Standard Python
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import math
# Les entrées effectuées dans ce noeud sont stockées sous forme de liste dans les variables IN.
a=IN[0]
b=IN[1]
c=IN[2]
d=IN[3]
Result=[]

# Placer votre code au-dessous de cette ligne
def Angle_ret(Xa,Ya,Xe,Ye):
	Dy=Ye-Ya
	Dx=Xe-Xa
	r=math.atan(Dy/Dx)
	t=r*180/math.pi
	a=t*200/180
	if Dy>0<Dx:
		return a
	elif Dy>0>Dx:
		return a+200
	elif Dy<0>Dx:
		return a+200
	elif Dy<0<Dx:
		return a+400
		
if not isinstance(a, list):
	a=[a]
if not isinstance(b, list):
	b=[b]
if not isinstance(c, list):
	c=[c]
if not isinstance(d, list):
	d=[d]
for i,j,k,l in zip(a,b,c,d):
	Result.append(Angle_ret(i,j,k,l))
# Affectez la sortie à la variable OUT.
OUT = Result

Note: your conditions 2 and 3 return the same value (a+200: curious)

Cordially
christian.stan

Hey @Thomas_Mahon and @christian.stan,

thx for your quick reply. Alright, the list-import and the iteration through the list was the missing part of it.

Thanks a lot guys for your help. Especially Christian, your script works fine. Great Job :slight_smile:

Cheers Max

1 Like