Angle Rotate with Python

Hey there!
I trying to make a python script that takes the X and Y from a list of vector’s and decides the rotation for each vector direction. I created this script in the Visual Studio and it’s working there, but when I tried to run in the python script node in the DYNAMO I always get a Empty List.
Why I get this Empty List?

This is the dynamo script:

And this is the Python Script:

# Carregar as bibliotecas DesignScript e padrão do Python
import sys
import clr
import System
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *


# As entradas para este nó serão armazenadas como uma lista nas variáveis IN.
X = IN[0]
Y = IN[1]
angle = []
c=0

# Insira o código abaixo desta linha
for i in X:
    if X[c]>0 and Y[c]==0:
        angle.append(90)
    if X[c]==0 and Y[c]>0:
        angle.append(180)
    if X[c]<0 and Y[c]==0:
        angle.append(270)
    if X[c]==0 and Y[c]<0:
        angle.append(360)
    c+=1
# Atribua a sua saída para a variável OUT.
OUT = angle

Hello @rinacimareller
can you paste your code here (edit your post), then select it and format the code with the </> button (in order to keep the syntax and the indentation levels)

1 Like

@rinacimareller
your script works fine, are you sure you have vectors with components X and Y equal to 0 ?

@rinacimareller ,

It could be because of list lacing & multiple list inputs, if that is the problem i would solve that by creating a custom node from your python code.

1 Like

@c.poupin thanks man, but i already find the answer. I just need to make a round inside the python script. Because tha vector Y isn’t exactly 0, is 2.8402746e-14. so the script can’t do the y==0.
But anyway, thanks for the help.

2 Likes