How Can I get start and end point using python


I am working on some python codes.
And I have some problem Could you please explain that how can I get start end point from curve.

Hi @eness.gun

retrieving start and end point is easy. You can use many ways to achieve it.

1 Like

You’ll want to be a bit careful of single items versus list items :slight_smile:

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

#Input variable of "Lines"
lines = IN[0]

#First we check if the item coming in is not already a list. We make it one if it is not. 
if not isinstance(lines, list):
    lines = [lines]

#Creating an empty container to put our results in
results = []

#Here we check each element (Line) inside the list (Lines)
for line in lines:
    #If there is one element, we treat it a different way to multiple
    if len(lines) > 1:
        #We append the results to our empty "results" container
        results.append([line.StartPoint, line.EndPoint])
    else:
        #We append the results to our empty "results" container
        results.append(line.StartPoint)
        results.append(line.EndPoint)

#We return our "results" container out of the Python node back to Dynamo
OUT = results
2 Likes

hello, very educational

thank you

Cordially
christian.stan

1 Like