List iteration | converting a revit point list to dynamo point list

Hi,
I wanted to convert my Revit.DB.Point list to dynamo point list.

The list I am trying to iterate is this.

image

I get the list length connected to IN[1].

List iteration
# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

# The inputs to this node will be stored as a list in the IN variables.
revit_xyz=IN[0]
pointlist_ListCount=IN[1]

# Place your code below this line
i=0
outputList=[]

for i in range(pointlist_ListCount):
    outputList.append(revit_xyz.ToPoint())  # I get error here.I can't get any attribute. 
    i=i+1

# Assign your output to the OUT variable.
OUT = outputList

I get this error: on this line of the code [ outputList.append(revit_xyz.ToPoint()) ] - AttributeError: ‘list’ object has no attribute 'To Point"

Could you please help me finding my mistake here?

You’re still converting the whole list inside your loop. If i is your index, then you need to get the item at that index every time with revit_xyz[i].ToPoint().

For a simpler solution, you can just use a for loop, which is specifically for iterating over items in a list:

for xyz in revit_xyz:
    outputList.append(xyz.ToPoint())

This will iterate over each point (xyz) in your list (revit_xyz) and allow you to interact with that item specifically.

2 Likes

thank you very much, I spent so much time to find a solution and kept looking at the sites to see an example (although there are many) I couldn’t do it. I really appreciated!