'List[object]' object has no attribute 'X'

Hello friends, I’m trying to access the list of X-Coordinate value from the list of Points in python script. But when I run the script it shows the following error. Would appreciate if could share their experience opinion. Thank you

Your input is an entire list and a list does not have a .X attribute. You’ll need to iterate over the list in your python script and then use .X on every item in your list.

listout = []
for point in StartPoints:
#Assign your output to the OUT variable.
OUT = listout
1 Like

Thanks @T_Pover. I was wondering what’s wrong with my following code. Why it is not giving me the correct output.

import clr
from Autodesk.DesignScript.Geometry import *
#The inputs to this node will be stored as a list in the IN variables.
StartPoints = UnwrapElement(IN[0]) #List of start points of each line
EndPoints = UnwrapElement(IN[1]) #List of end points of each line

NewStartPoints = []
NewEndPoints = []

#Assign your output to the OUT variable.

for i in range(len(StartPoints)):
	for j in range(len(EndPoints)):
		if ((StartPoints[i].Y) == (EndPoints[j].Y)): #This code is not working, WHY?

OUT = NewStartPoints, NewEndPoints

That;s because the Y values are inaccurate due to rounding issues, you will have to check if their values are almost equal.

1 Like

Yes, I thought that so. I was thinking there might be some work around for it. Anyway what I did was cast the values to integer than compare it. After that it was working. Thank you for your help. Appreciate it : -)
if (int(StartPoints[i].Y) == int(EndPoints[j].Y)):

1 Like