 # Polyline vertices incl. start and end vertices?

I just started using Dynamo today, so bear with me if I am babbeling.

I have a list of polylines,

list
 list
Polycurve (NumberOfCurves = 3)
Polycurve (NumberOfCurves = 2)
etc…

And I need to extract a list of all of the vertices - including start and end vertex.

So I made a PolyCurve.Curves and got a nice list with all the vertices.

list
 list
 list
Curve(StartPoint = Point(x,y,z), EndPoint = Point(x,y,z)
Curve(StartPoint = Point(x,y,z), EndPoint = Point(x,y,z)
Curve(StartPoint = Point(x,y,z), EndPoint = Point(x,y,z)
Curve(StartPoint = Point(x,y,z), EndPoint = Point(x,y,z)
 list
Curve(StartPoint = Point(x,y,z), EndPoint = Point(x,y,z)
Curve(StartPoint = Point(x,y,z), EndPoint = Point(x,y,z)
Curve(StartPoint = Point(x,y,z), EndPoint = Point(x,y,z)

How can I transform this list into a list of lists of all the vertices once?

list
 list
 Point(xyz) - this is the startpoints
 Point(xyz) - this is the startpoints
 Point(xyz) - this is the startpoints
 Point(xyz) - this is the startpoints
 Point(xyz) - this is the Endpoint of last line
 list
 Point(xyz) - this is the startpoints
 Point(xyz) - this is the startpoints
 Point(xyz) - this is the startpoints
 Point(xyz) - this is the Endpoint of last line

I expect this needs some Python, and while I do code C++, the Python syntax eludes me.

You will find a lot of information that helps to get started with Dynamo in the Primer:
http://dynamoprimer.com/en/05_Geometry-for-Computational-Design/5-1_geometry-overview.html
As well as in the Dictionary:
http://dictionary.dynamobim.com/#/Geometry/Curve/Query/StartPoint

I figured it out - I was not deep enough into the lists.

"
import clr
#from Autodesk.DesignScript.Geometry import *

def BuildLines(pLine):
layerList=[]
for i in range(len(pLine)):
curveList=[]
for j in range(len(pLine[i])):
lineList=[]
for k in range(len(pLine[i][j])):
lineList.append(pLine[i][j][k].StartPoint)
lineList.append(pLine[i][j][k].EndPoint)
curveList.append(lineList)
layerList.append(curveList)

``````return layerList
``````

OUT=BuildLines(IN);
";

hi, I need the exact same thing - the list of start, all vertices, end vertex.

but my polycurve is already made out of 3 joined detail lines. - because i need the vertices in the correct order since i want to draw a wire. (this is why i need all the vertices) it doesn’t seem like i can extract much out of this node.
I have the detail lines selected in a “select model elements” node, but the order there is random…

Maybe a little bit of Python could help.

``````# Load the Python Standard and DesignScript Libraries
import sys
import clr
from Autodesk.DesignScript.Geometry import *

# The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN

# Place your code below this line
pCrv = IN

crvs = pCrv.Curves()
verts = []
verts.extend(c.StartPoint for c in crvs)
verts.append(pCrv.EndPoint)
# Assign your output to the OUT variable.
OUT = verts
``````

a part from that I think maybe there exists a node for this in the Wombat package. Unsure if it is still maintained.

3 Likes

thank you for the code always nice to study it.

found these in Dynamo:

now the vertices are taken in the correct order This is nice. Thank you for this.
Though it fails for list of polycurves.

Regards,
Atharva Purohit